Skip to content

akawalko/laminas-auth-redbean-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

laminas-auth-redbean-adapter

What is this

It's an authentication adapter for a great library called Laminas\Authentication

It focuses on replacing the default database adapter, Laminas\Db\Adapter\Adapter from library Laminas\Db, with an adapter derived from a lightweight ORM called RedBeanPHP.

Replacing the database adapter necessitated replacing Laminas\Db\Sql\Select (part of the same Laminas\Db library) with something that would provide similar functionality. To avoid wasting dozens of hours writing my custom SQL query builder, I opted to use an excellent library that does not require establishing a connection to the database to generate a query.

SQL Query Builder by Nil Portugués Calderó provides an elegant lightweight and efficient SQL Query Builder with fluid interface SQL syntax supporting bindings and complicated query generation.

Apart from replacing the database adapter and the SQL query builder, the main improvement over the original is the ability to have full control over the number of columns returned from the database. Example no. 3 shows how this can be done. This can be a big advantage for tables that have a large number of columns. The minimum number of columns returned is 2, one for the identity column, the other for the password. For obvious reasons, a column with user ID will also be useful, but it is not required.

Install

Require

  • php: >=7.4
  • gabordemooij/redbean (can be installed in 2 ways, that's why I omitted this package in composer.json)
composer require akawalko/laminas-auth-redbean-adapter

Usage

After installing the package, read the Laminas\Authentication documentation at https://docs.laminas.dev/laminas-authentication/

Be sure to also check out the folder with examples I have prepared for you: https://github.com/akawalko/laminas-auth-redbean-adapter/tree/main/examples

Before you run any example, make sure you have created a database and a user account that provides access to it, and have also executed the SQL commands from the db_structure_mysql.sql (or db_structure_sqlite.sql) and db_entries.sql files.

About

Laminas authentication adapter using a lightweight ORM called RedBeanPhp

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages