First, download and install composer
2, installation
Middle option can not be ignored operate directly next to complete the installation
3, complete
Enter cmd composer following message appears to prove the end of the installation
4, Chinese mirroring configuration
Fast down the package, you can ignore this step unnecessary. Direct input commands in cmd
Command address
Two, laravel application
1, the installation
Previous article introduced here do not explain too much, keep in mind here
laravel项目中的所有相对路径都是相对 publiuc/index.php 入口文件定义
laravel installation
2, routing settings Home
File Locations
app/Http/routes.php
Home routing format, more detailed laravel route and the need to pay attention to the use of pseudo-static configuration
//这里输出文字
Route::get('/', function () {
return '这是首页';
});
The following example page rendering
Page rendering template default storage location:
resources\views\web\index.blade.php
web.index
: Web custom function file in the views folder path as a distinguishing foreground, background and other functions. web is the folder index view template is a fixed format suffix.blade.php
can also be created directly in the views belowindex.blade.php
call the following format:return view('index',['name'=>'jack','age'=>30]);
view(视图模版,参数数组)
//页面渲染
Route::get('/', function () {
return view('web.index',['name'=>'jack','age'=>30]);
});
3, Magical middleware
中间件使用好事半功倍, 建议好好阅读中间件的使用 。当然不用一样不影响开发
laravel log requests using global middleware, the middleware detecting local log practical case
4, the controller (emphasis)
Create a controller applications focus on explaining
The Controller laravel learning parameterized request, alias, middleware application, a RESTful
5, Http response
Grammar usage herein with reference to the latest official usage
laravel6.0 response to Chinese documents
6, view template
The syntax of view but to introduce more comprehensive official is very detailed. Be sure to development in accordance with the official documents
laravel6.0 view Chinese documents
Using Variables way{{参数}}
laravel6.0 die in this document Chinese document
//index.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
<h1>admin name: {{$name}}</h1>
<h1>admin age: {{$age}}</h1>
</body>
</html>
7, database
Mysql do for introduction
File Location: config \ database.php
There's
env
method is to do what? Why not write directly to the database address?
env()
Is laravel built-in method. This is mainly inside reads.env
configuration information file. If the configuration parameter is not set, then use the second default parameters
so you can change the database configuration information directly in this position, but it is preferable.env
to modify the configuration file
database.php:
//其他配置....
//mysql
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
//其他配置....
.env file configuration parameters:
...
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
...