Laravel directory structure

App directory

Project core directory, mainly storage controller, model

Model directory

The controller

Auth controller is managed by directory

Controller.php base class Controller, which any Controller you write will inherit

User authentication module (example)

Bootstrap

config

The configuration file

App.php: Main configuration file of the project

Auth.php: Configuration file used to define user authentication (login)

Database.php: configures the Database

Fliesystems.php: uploads the file and stores the configuration file to be used

database

Data Migration directory

Migrations Stores action files related to tables (create table class files)

Seeds file

public

Single junction index.php

Routes

The directory that defines the route. Web.php is the file that defines the route

Storage file

App: Stores files uploaded by users

Frameword: A cached file used when the framework is running

Logs: log directory

.env

Environment configuration file information related to the system. Configuration information in the config directory is generally read from this file. (The value of configuration items in config is basically from the. Env file.)

artisan

Framework scaffolding files, mainly used to automatically generate code, such as controllers, model files, etc

Execute command: # PHP artisan need to execute the command

composer.json

Dependency package configuration files

How the framework starts:

 #php artisan serve
Copy the code

routing

Routing: the user’s request is delivered to the specified controller or function for processing according to the pre-planned scheme.

Routing is the form of access address.

1. Route configuration file

routes/web.php

2. Route definition format

Route: : Request method (‘ requested URL ‘, anonymous function or controller response method)

User-defined routing mode

When both Post and GET are required

3. Route parameters

Routing parameters

Parameters are optional and mandatory

Route parameters are passed in the format of {parameter name} in the route address. This format is mandatory. Optional parameters are passed in the format of {parameter name? }”

Will choose parameters

Optional parameters

Through? Way to pass parameters

4. Route alias

It is equivalent to creating an alias for the route when defining the route. You can use this alias to obtain route information in future programs

Route::get(‘/’, function () {

return view(‘welcome’);

}) -> (‘ name ‘);

This route can be written as route (‘ name ‘);

5. Array groups