Laravel 5.1 升级 5.2
从5.1升级到5.2预计时间一个小时,升级的过程,按照官方的升级指导,基本没遇到什么大的问题,所以建议按照指导走即可。
遇到的问题如下:
FatalErrorException in BusServiceProvider.php line 16:
Call to undefined method Illuminate\Bus\Dispatcher::mapUsing()
解决方案:
删除config/app.php
里面的App\Providers\BusServiceProvider
即可。这是由于从5.0升级到5.1时忘记删除而导致的。
Laravel 5.2 升级 5.3
从5.2升级5.3预计时间为2-3个小时,首先还是按照官方指导全部修改过来,其中还是会遇到不少问题。
问题一:
[Symfony\Component\Debug\Exception\FatalErrorException] Class App\Providers\BroadcastServiceProvider contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate\Support\ServiceProvider::register)
解决方案:
在config/app.php
文件里面在App\Providers\BroadcastServiceProvider
前面添加
Illuminate\Broadcasting\BroadcastServiceProvider
问题二:
InvalidArgumentException: Broadcaster [] is not defined.
解决方案:
在config目录里面添加broadcasting.php
配置文件,具体内容参考https://raw.githubusercontent.com/laravel/laravel/master/config/broadcasting.php
问题三:
[2017-03-29 18:02:42] local.ERROR: ErrorException: Declaration of App\Providers\EventServiceProvider::boot(Illuminate\Contracts\Events\Dispatcher $events) should be compatible with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot() in C:\wamp64\www\sfabric\app\Providers\EventServiceProvider.php:6
解决方案:
其实在官方指导里面提到:
You may remove the arguments from the boot method on the EventServiceProvider, RouteServiceProvider, and AuthServiceProvider classes.
也即是说将这三个类boot方法的参数都删掉,需要用到系统方法的,直接使用Facade即可。
例如:
public function boot()
{
$this->registerPolicies();
Passport::routes();
Gate::before(function ($user, $ability) {
//超级管理员不做权限验证
if ($user->isSuperAdmin()) {
return true;
}
//检查是否开启ACL
if (config('acl.auth') === false) {
return true;
}
});
}
问题四:
Maatwebsite/Laravel-Excel
和5.3不兼容的问题
解决方案:
将版本号改为如下"maatwebsite/excel": "2.1.x-dev"
即可
问题五:
php artisan route:list
RuntimeException: Session store not set on request.
解决方案:
将所有控制器里面的$request->session()
改为session()
即可
参考网站:
- While upgrading 5.1 to 5.2
- Fatal error while upgrading Laravel 5.1 to 5.2
- Weird error upgrading to 5.3
- 5.3 Upgrade Error: BroadcastServiceProvider contains abstract method
- I used composer to upgrade to Laravel 5.3, which broke it
- Can't use the package with Laravel 5.3
- php artisan route:list RuntimeException Session store not set on request