我想将现有的 Laravel 9 项目升级到版本 10。目标是,不仅供应商文件可以通过 Composer 更新。此外,我还想在供应商文件夹之外反映我的项目代码中的更改。
我按照 Laravel 文档的升级指南升级了我的项目。
这是已更改的文件。
例如我的 app/Console/Kernel.php 应该更改为
command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
至
command('inspire')->hourly();
}
/**
* Register the commands for the application.
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
自动更新此类“示例”文件可能根本不可能自动进行,因为用户可以在其项目中编辑它们,这就是它们不在供应商中的原因。
更新 PHP 相关语法(例如提到的类型提示)的最佳选择可能是具有适当规则的 PHP-CS-Fixer 之类的东西,但您的函数示例无法使用它,因为这需要旧的定义方式通过 PHPDoc 返回类型。
如果您修改了这些文件,则可以从 Laravel 存储库手动复制这些更改并将其调整为您的代码。