Loading...
Loading...

Login & Registration

generate login method and creation of new users

login-registration-generator

Generate your Laminas MVC User Registration for creating new user accounts together with logging-in feature according to the ACL permissions.

Video Tutorial


Required Laminas Components

  1. laminas/laminas-db
  2. laminas/laminas-math
  3. laminas/laminas-session
  4. laminas/laminas-serializer
  5. remember to include new css file

Required Laminas Starter Kit Components

  1. mariadb-database-connect

On-line Generator

Setup Instructions

  1. Ensure you have module called: %module% in your application.
  2. Create PHP files called RegisterController.php, LoginController.php and UserController.php in: [root]/module/%module%/src/Controller/ and paste the contents from above.
  3. Create a view file called index.phtml in: [root]/module/%module%/view/register/ and paste the contents from register/index.phtml.
  4. Create a view file called index.phtml in: [root]/module/%module%/view/login/ and paste the contents from login/index.phtml.
  5. Create a view file called index.phtml in: [root]/module/%module%/view/user/ and paste the contents from user/index.phtml.
  6. Create a PHP file called UserFormHydrator.php in: [root]/module/%module%/src/Hydrator/ and paste the contents from above.
  7. Create PHP files called UserLoginFieldset.php, UserLoginForm.php, UsernameFieldset.php and UserRegisterForm.php in: [root]/module/%module%/src/Form/ and paste the contents from above.
  8. EDIT a PHP config file called global.php in: [root]/config/autoload/ and add the contents from above.
  9. EDIT a PHP config file called module.config.php in: [root]/module/%module%/config/ and add the contents from above.
  10. EDIT a PHP config file called Module.php in: [root]/module/%module%/src/ and add the contents from above.
  11. Create PHP files called AbstractTable.php and UserTable.php in: [root]/module/%module%/src/Model/ and paste the contents from above.
  12. Create PHP files called AbstarctModel.php and User.php in: [root]/module/%module%/src/Model/Rowset/ and paste the contents from above.
  13. add: ->prependStylesheet($this->basePath('css/login-register.css'))
  14. Copy and run the SQL from [root]/module/sql/users.sql file via PHPMyAdmin or other DB tool, to create a required database table.

Throubleshooting

Make sure your application contains all the required plugins from "Required Laminas Components" and "Required Laminas Kit Components".
You can learn how to add missing dependencies in this video:

Parameters

Param name Type Default value Description
module text NULL Sets a module name
properties array NULL Sets users table properties

CLI Usage

"vendor/bin/laminas.bat" mvc:login_register --properties=<property1> --properties=<property2> --module=<moduleName>

Example Usage

"vendor/bin/laminas.bat" mvc:login_register --properties=name --properties=email --properties=password --module=Application

Learn more with Laminas Book:

Laminas MVC: the most innovative framework in PHP - get a book on Amazon

Need help? Checkout our setup page, video tutorials or ask questions on our forum!

Help Tutorials Forum
TOP