一刻升級之路 整理好的文件:
https://github.com/laravel/vonage-notification-channel/blob/3.x/UPGRADE.md
Composer update 篇 改composer.json
將 laravel/framework 改版本
其他套件可能視情況也要一起調整
PHP Fatal error: Declaration of App\Exceptions\Handler::report(Exception $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Throwable $e) in … ru; Call to undefined function str_slug()
COMPOSER_MEMORY_LIMIT=-1 composer require laravel/helpers
Class 'Illuminate\Http\Resources\Json\Resource' not found
這個影響有點大
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
https://laravel.com/docs/7.x/upgrade#symfony-5-related-upgrades
要改 use Illuminate\Http\Resources\Json\Resource
變成 use Illuminate\Http\Resources\Json\JsonResource
如果有用 resource
這個class name 就要改成`use Illuminate\Http\Resources\Json\JsonResource as Resource;
`
跑 phpunit 篇 phpunit.xml:Your XML configuration validates against a deprecated schema.(警告)
vendor/bin/phpunit --migrate-configuration
Error: Call to undefined function Tests\Feature\Admin\V1\factory()
COMPOSER_MEMORY_LIMIT=-1 composer require laravel/legacy-factories --dev
// composer.json
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
原本寫0 可以通過的test 但到了升級之後那裏嚴謹需要false才會通過 ReflectionException: Class Barryvdh\Cors\HandleCors does not exist
laravel 7 以支援Cors,可以直接移除試試看
TypeError: Argument 2 passed to Symfony\Component\HttpFoundation\Request::setTrustedProxies() must be of the type int, array given 其他篇 route:cache Unable to prepare route [api/admin/v1/priceitem_groups] for serialization. Another route has already been assigned name In RouteFileRegistrar.php line 35:Array to string conversion php artisan config:cache
注意自己的.env 配置, 在7還是8之他會根據你在APP_ENV的設定讀取像是.env.testing 或.env.local, 導致在執行指令後感覺反而沒有apply的感覺
upgrade to php8 篇
TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, function "imagejpeg" not found or invalid function name
upgrade to 9 調整 trustedproxy.php
#8 0.516 In trustedproxy.php line 48:
#8 0.516
#8 0.516 Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL
解決方法: https://laravel.com/docs/9.x/upgrade#the-assert-deleted-method
jwt-auth 不支援 laravel-9 https://github.com/tymondesigns/jwt-auth/issues/2141
先暫時改用 php-open-source-save/jwt-auth
https://github.com/PHP-Open-Source-Saver/jwt-auth
同事反映: swagger 問題?! phpunit faker 問題 https://stackoverflow.com/questions/66481327/how-to-fix-error-abandoned-fzaninotto-faker-packagist-in-composer-2-0-11-version