Home  >  Article  >  Backend Development  >  Laravel framework routing settings

Laravel framework routing settings

不言
不言Original
2018-06-12 16:39:502674browse

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 resources

Find

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=&#39;stylesheet&#39; type=&#39;text/css&#39;>
<link href="css.css" rel="external nofollow" rel=&#39;stylesheet&#39; type=&#39;text/css&#39;>
<!-- 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 install

php 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=secret

Then, we use laravel's migrate to migrate the database

php artisan migrate

When 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn