Laravel route settings and sub-route settings instance analysis, laravel instance Analysis _ PHP Tutorial

Source: Internet
Author: User
Laravel routing settings and sub-router configuration instance analysis, laravel instance analysis. Laravel route settings and vro settings are analyzed by using the laravel instance. This article describes the Laravel route settings and vro settings. For your reference, the details are as follows: Laravel routing settings and vro settings instance analysis and laravel instance analysis.

This example describes how to set Laravel routing and vro. We will share this with you for your reference. The details are as follows:

Common route settings

1. routing (routes. php) Code:

Route::get('min','MinController@index');

Min: Route name, that is, the name entered in the url. for example, 127.0.0.1/min. here, min is the corresponding min.
MinController is the file name (class name)
@ Index indicates the method name.

2. Controller

namespace App\Http\Controllers;use App\Http\Controllers\Controller;class MinController extends Controller{  public function index(){     $name = 'Specs1';    return view('index')->with('name',$name);  }}

Vro

1. routing:

Route: group (['namespace' => 'min'], function () {Route: get ('min/{index} ', 'mincontroller @ index '); // The {index} here is similar to a regular expression, that is, the url can be randomly entered: 127.0.0.1/min/$ index is like a variable, and everything can be input. But @ index is the real method });

Controller:

Namespace App \ Http \ Controllers \ Min; // Min is the Controller's folder path, use App \ Http \ Controllers \ Controller; class MinController extends Controller {public function index () {$ name = 'specs1'; return view ('min. index')-> with ('name', $ name); // min here. index is equivalent to min/index, which is the index under the min view folder. blade. php file }}

Structure:

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.