laravel 新版本问题使用route:cache的问题
1. 运行环境
1). 当前使用的 Laravel 版本?
Laravel Framework 10.35.0
2). 当前使用的 php/php-fpm 版本?
PHP 版本:PHP 8.1.21
php-fpm 版本:PHP 8.1.21
3). 当前系统
Ubuntu 22.04
4). 业务环境
开发环境
2. 问题描述?
我将版本降级回10.20.0
是没有问题的,升级到10.35.0
直接报错,下面是web.php
路由文件
<?php
use Illuminate\Support\Facades\Route;
$log = app('log');
Route::any('{all}', function () use ($log) {
});
运行php artisan route:cache
之后直接报错
3. 您期望得到的结果?
INFO Routes cached successfully.
4. 您实际得到的结果?
Exception
Serialization of 'WeakMap' is not allowed
at vendor/laravel/framework/src/Illuminate/Routing/Route.php:1344
1340▕ public function prepareForSerialization()
1341▕ {
1342▕ if ($this->action['uses'] instanceof Closure) {
1343▕ $this->action['uses'] = serialize(
➜ 1344▕ SerializableClosure::unsigned($this->action['uses'])
1345▕ );
1346▕ }
1347▕
1348▕ if (isset($this->action['missing']) && $this->action['missing'] instanceof Closure) {
+14 vendor frames
15 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
下面是版本截图
我也测试
10.35.0
,确实不行,这应该算是官方的bug。想用
10.35.0
,可以换个方式