Laravel uses simple routing to operate routes in the Laravel framework in response to HTTP actions. Simply put, you can input a URL in the webpage to transfer the URL to the corresponding route in the Laravel framework, the corresponding functional routing can be formed to receive a URL and a closure method, and the position in the laravel framework is route. php file is a very simple routing example:
Route::get('/', function () { return 'Hello World';});Route::get('admin', function () { return 'Hello World!!!';});
In route. after the preceding two routes are defined in the php file, start the laravel framework server, run the php artisan serve command, and enter localhost: 8000 in the browser, then, call the closure function of the first route, and the Hello World corresponding to the first route appears. The difference between the second route is that a path prefix is added, that is, when you enter localhost: 8000/admin in the browser, the closure function in the second route is called and Hello World !!!
I think some people may not know where to enter the startup command to open the console. mac OS or Linux is to open the terminal and enter the folder of your framework, enter the startup command in the folder containing the artisan file. If an error occurs, go to Baidu and GOOGLE.
All the business logic is implemented in the routing, that is, the closure function of the routing completes all the work directly. in actual development, the business logic is very huge, it is impossible to implement in the closure function. in principle, the use of the laravel framework is not allowed, so it is necessary to transfer the route to another very simple routing example in the controller:
Route::get('/', 'HomeController@index');
After the route is defined, start the service and enter localhost: 8000 in the browser, the index method in the HomeController. php file will be called.
HomeController. php is a Controller file. the laravel framework is implemented based on the MVC framework. in the laravel 5.1 Directory, the Controller folder under the HTTP folder is the Controller part in MVC, the routing function in the laravel framework is to pass browser requests to the framework to start the corresponding functions in the framework.
The above are two simple routing operations. I will write a browser --> route --> controller --> view --> complete routing operations on the browser. I am also a newbie and work together.