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
- laminas/laminas-db
- laminas/laminas-math
- laminas/laminas-session
- laminas/laminas-serializer
- remember to include new css file
Required Laminas Starter Kit Components
On-line Generator
Setup Instructions
- Ensure you have module called: %module% in your application.
- Create PHP files called RegisterController.php, LoginController.php and UserController.php in: [root]/module/%module%/src/Controller/ and paste the contents from above.
- Create a view file called index.phtml in: [root]/module/%module%/view/register/ and paste the contents from register/index.phtml.
- Create a view file called index.phtml in: [root]/module/%module%/view/login/ and paste the contents from login/index.phtml.
- Create a view file called index.phtml in: [root]/module/%module%/view/user/ and paste the contents from user/index.phtml.
- Create a PHP file called UserFormHydrator.php in: [root]/module/%module%/src/Hydrator/ and paste the contents from above.
- 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.
- EDIT a PHP config file called global.php in: [root]/config/autoload/ and add the contents from above.
- EDIT a PHP config file called module.config.php in: [root]/module/%module%/config/ and add the contents from above.
- EDIT a PHP config file called Module.php in: [root]/module/%module%/src/ and add the contents from above.
- Create PHP files called AbstractTable.php and UserTable.php in: [root]/module/%module%/src/Model/ and paste the contents from above.
- Create PHP files called AbstarctModel.php and User.php in: [root]/module/%module%/src/Model/Rowset/ and paste the contents from above.
- add: ->prependStylesheet($this->basePath('css/login-register.css'))
- 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:
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