[Laravel] basic use of Laravel

Source: Internet
Author: User
[Laravel] basic use of Laravel [Laravel] basic HTTP route of Laravel & nbsp; use the basic route of Laravel to implement get request response and find the file appHttproutes. php calls the Route static method get () to implement the get Response. the parameter is a string-type path, and the anonymous function () {} is inside the anonymous function, returns string data & [Laravel] Basic usage of Laravel

[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 \ [email protected]");,

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.