Laravel 5.5 已发布,这是最新的长期支持版本(LTS),包含多项改进。 发行说明:https://laravel-news.com/laravel-5-5 部分亮点: Whoops Package 回归 filp / whoops package 曾经出现在 V4 系列,用于在调试时提供优雅的堆栈跟踪,是一个错误处理框架。Laravel 5.5 版本 Whoops Package 正式回归。 Exception Rendering 5.5 无需额外的逻辑,可直接抛出异常,并进行响应: <?php // throw new TerribleSongException($song) in a controller... namespace App\Exceptions; use App\Song; class TerribleSongException extends \Exception { /** * @var \App\Song */ protected $song; public function __construct(Song $song) { $this->song = $song; } /** * @param \Illuminate\Http\Request $request */ public function render($request) { return response("The song '{$this->song->title}' by '{$this->song->artist}' is terrible."); } } 自定义验证规则对象 Laravel 5.5 带来新的自定义验证规则对象,以此作为 Validator::extend 的替代方法。新规则的逻辑更一目了然: <?php namespace App\Rules; use Illuminate\Contracts\Validation\Rule; class CowbellValidationRule implements Rule { public function passes($attribute, $value) { return $value > 10; } public function message() { return ':attribute needs more cowbell!'; } } 使用新规则后: <?php request()->validate([ 'cowbells' => [new CowbellValidationRule], 'more_cowbells' => [function ($attribute, $value, $fail) { if ($value <= 10) { $fail(':attribute needs more cowbell!'); } }] ]); Blade::if () 指令 新的指令包括 @auth and @guest @auth Welcome {{ user()->name }}! @endauth @guest Welcome Guest! @endguest 新的迁移命令:Fresh 新的 migrate:fresh 命令会直接删除所有的表,然后运行迁移。通常在开发过程中,你也只需删除表,获取新数据库,和运行迁移。 更多细节请直接查看发行说明 Laravel 5.5 更多链接: 升级文档:https://laravel.com/docs/5.5 版本说明 https://laravel.com/docs/5.5/releases 升级指南:https://laravel.com/docs/5.5/upgrade Laravel 5.5 LTS 正式发布,Whoops Package 回归下载地址