Laravel

主页

GitHub

Release Notes

10 September, 2022
9 September, 2021
https://laravel.com/docs/8.x/releases September 8th, 2020
https://laravel.com/docs/7.x/releases March 3rd, 2020
https://laravel.com/docs/6.x/releases September 3rd, 2019
https://laravel.com/docs/5.8/releases February 26th, 2019
https://laravel.com/docs/5.7/releases September 4th, 2018
https://laravel.com/docs/5.6/releases February 7th, 2018
https://laravel.com/docs/5.5/releases August 30th, 2017

支持数据库 MySQL、PostgreSQL、SQLite、SQL Server,所有版本默认不支持Oracle。不同Laravel版本数据库支持的版本不同。

Laravel 8 开始官方文档都是用Docker部署,且推荐使用Homestead作为开发环境

Issues

artisan

查看可用命令

1
php artisan list

运行项目

1
2
3
php artisan serve // 启动
--host 192.168.1.101 // 指定ip
--port 80 // 指定端口

查看路由列表

1
php artisan route:list

生成

1
2
3
4
php artisan key:generate	生成AppKey
php artisan make:controller 创建控制器
php artisan make:middleware 创建中间件
php artisan make:model 创建模型

清楚缓存

1
php artisan config:clear

Laravel Mix

Laravel Validation

Introduction

Laravel includes a wide variety of convenient validation rules that you may apply to data, even providing the ability to validate if values are unique in a given database table.

Writing The Validation Logic

1
2
3
4
$validated = $request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);

validation rules may be specified as arrays of rules instead of a single | delimited string

1
2
3
4
$validatedData = $request->validate([
'title' => ['required', 'unique:posts', 'max:255'],
'body' => ['required'],
]);

Stopping On First Validation Failure

1
2
3
4
$request->validate([
'title' => 'bail|required|unique:posts|max:255',
'body' => 'required',
]);

A Note On Nested Attributes

1
2
3
4
$request->validate([
'author.name' => 'required',
'author.description' => 'required',
]);

References