[Laravel] basic use of Laravel, which is used by laravel. [Laravel] basic use of Laravel. laravel uses the basic HTTP route of [Laravel] Laravel using the basic route of Laravel to implement get request response and find the file appHttproutes. php calls R [Laravel] the basic usage of Laravel. laravel uses
[Laravel] basic HTTP routing of Laravel
Use the basic routing of Laravel to implement get request response and find the file app/Http/routes. php
Call the Route static method get () to implement get Response. parameter: string path, anonymous function (){}
Returns string data within an anonymous function.
Post, put, and delete requests, same as above
Implement the Route for passing parameters through get, call the Route static method get (), parameters: Path, anonymous function
Path, parameter name of the braces, excluding $, for example, '/user/{id }'
Anonymous function, receiving parameters, such as: function ($ id ){}
[Laravel] basic controller of Laraval
Create an Index/IndexController. php file in the app/Http/Controllers directory.
Define namespace App \ Http \ Controllers \ Index
Introduce the Controller basic Controller, use App \ Http \ Controllers \ Controller
Define IndexController to inherit Controller
Implementation method index, return data
Define the behavior of a Route controller, for example, Route: get ("/index", "Index \ IndexController @ index ");,
Note that in the namespace section, the newly created controller is under the root namespace. add the newly added namespace when specified.
[Laravel] basic view of Laravel
Under the resources/views/directory, create index/index. php
Use the function view () in the controller to call the template. parameters: file path (. separated directory), data
Route: routes. php
['Web'], function (){//});
Controller: IndexController. php
Template: index. php
Http://www.bkjia.com/PHPjc/1117666.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1117666.htmlTechArticle[Laravel] Laravel is basically used. laravel uses the basic HTTP route of [Laravel] Laravel to implement get request response and find the file app/Http/routes. php calls R...