Home > Article > Backend Development > Laravel framework routing settings
This article mainly introduces the setting and use of Laravel framework routing. It analyzes the setting method of Laravel framework routing and related operation precautions in the form of examples. Friends in need can refer to it.
This article describes Laravel with examples. Framework routing setup and usage. Share it with everyone for your reference, the details are as follows:
Laravel installation, here use the one-click installation package.
Use PHP's built-in web server and run the command line under the PHP folder
php -S 0.0.0.0:1024
1. Set routing
The routing file is in app\HTTP\routes.php, add
Route::get('/hi', function () { return 'hello world'; });# in the code ##We observed that this PHP file already contains
Route::get('/', function () { return view('welcome'); });. Therefore, the routing file specifies which view the URL should turn to. Laravel loads so slowly! The main reason is that Google fonts are quoted, and the cdn speed is not fast. We can change the referenced resources to static resourcesFind
app.blade in the directory \resources\views\layouts .php file, change the css reference to
<!-- Fonts --> <link href="font-awesome.min.css" rel="external nofollow" rel='stylesheet' type='text/css'> <link href="css.css" rel="external nofollow" rel='stylesheet' type='text/css'> <!-- Styles --> <link href="bootstrap.min.css" rel="external nofollow" rel="stylesheet">The speed will be faster!
2. Install the authentication system
Use artisan command line to installphp artisan make:auth
Go to the laravel folder at this time and observe that a .env file and .env.example file are generated. We edit the .env file to configure the mysql database
DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secretThen, we use laravel's migrate to migrate the database
php artisan migrateWhen we complete this step, 3 new tables have been created in the mysql database. Access URL:
http://127.0.0.1:1024/laravel/public/login
The above is the entire article Content, I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website! Related recommendations:The use of action classes in Laravel program architecture design
Laravel framework implements operations using middleware Logging function
The Laravel framework implements the sql statement recording function using the listener
The above is the detailed content of Laravel framework routing settings. For more information, please follow other related articles on the PHP Chinese website!