Todo:laravel built-in simple login
1. Activating the Laravel auth system laravel The new features of PHP trait built-in simple user login registration function, suitable for some systems that do not require complex user rights management, such as the company's internal simple management system. Run the following command:
PHP Artisan Make:auth
Run successfully display
Authentication scaffolding generated successfully.
2. Added in the routing code
Auth::routes ()
The main implementation of the permissions of the login, user registration, user exit
Login to access Http://127.0.0.1:8000/login:
User Registration Http://127.0.0.1:8000/register:
The/home page will not be accessible until login is successful, otherwise it will remain on the login page
3. Simple analysis of auth code, as long as the need to add the controller's PHP code to add the constructor auth code,
Can see Authorizesrequests, dispatchesjobs, validatesrequests are Trait;auth is in a middleware mode is added to the code, middleware is laravel to an important part, We can also create middleware for use. Laravel Middleware has auth,web,http,route,session,view and so on, creating a middleware approach is simple:
PHP Artisan make:middleware Middleware Name
4. Change the relevant page of the permission to Semantic-ui style, as long as the code under the Auth @ extends changed to @extends (' Layouts.main ') that is, the switch is very convenient.
5. Since PHP 5.4.0, PHP implements a code reuse method called trait. Trait is a code reuse mechanism that is prepared for PHP-like single-inheritance languages. Trait to reduce the limitations of single-inheritance languages, developers are free to reuse method in separate classes within different hierarchies. The semantics of Trait and class combinations define a way to reduce complexity, avoiding traditional multi-inheritance and Mixin class-related typical problems. Members that inherit from the base class are overwritten by the members that are inserted by trait. Precedence is the method from which the member of the current class overrides the trait, and trait overrides the inherited method. The trait used by Laravel Auth have Handlesauthorization,authenticatable,createsuserproviders,guardhelpers,canresetpassword, Trait is also very simple to use, as long as you add the name of using trait in class.
6. Simple system login is complete.
Wxgzh:ludong86
Todo:laravel built-in simple login