I wanted to update from Laravel 5.5 to 10. My php version is 8.1.5 but facing many problems to update directly here. Especially ,
requires php ^7.3 -> your php version (8.1.5) does not satisfy that requirement.
if it can’t be updated directly, what steps should be taken? I have attached my Composer json file below.
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"barryvdh/laravel-dompdf": "^0.8.4",
"fideloper/proxy": "~3.3",
"gloudemans/shoppingcart": "^2.5",
"intervention/image": "^2.4",
"laravel/framework": "10",
"laravel/tinker": "~1.0",
"niklasravnsborg/laravel-pdf": "^3.1",
"shipu/php-aamarpay-payment": "^1.0",
"milon/barcode": "^5.2",
"yajra/laravel-datatables": "1.5"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0",
"symfony/thanks": "^1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"scripts": {
"post-root-package-install": [
"@php -r "file_exists('.env') || copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"extra": {
"laravel": {
"dont-discover": [
"laravel/dusk"
]
}
}
}
I wanted to take version 8 first, then 9 and 10 one by one, but mPDF caused the most problems.
Please help me I am beginner.
2
Answers
First, u need to upgrade PHP version (^8.0) in your machine and composer file then upgrade your dependency.
Follow the documentation for upgrading guide.
A little background:
A
composer.json
file is an important part of any PHP package. Therequire
andrequire-dev
sections are a place where you list out the external packages that your code depends on. Within these sections you have control over which versions of these external packages can/should be installed. This means you can exclude any versions that prove to break your code. Usually there will be a range of valid version (accomplished by version constraints) although sometimes it may be only one exact version.Just like your code is a package (in part because it has a
composer.json
file) , every package that you include in yourrequire
andrequire-dev
sections has acomposer.json
file of their own. And just like you get to specify your dependencies and their versions, each external package gets to specify those for itself.When you run
composer update
, composer looks through everycomposer.json
file recursively and and tries to find 1 single version for every required package that satisfies every package’s require sections. If it’s successful, composer installs the packages. If not, you’ll get an error like:Your requirements could not be resolved to an installable set of packages.
Followed by more detail about the issues.Answer
It would be helpful if you would post your entire composer error message. But since you are specifying and PHP version greater than 7.0 in your
composer.json
, but composer is showing you that ^7.3 is required, I’m guessing that PHP ^7.3 (which means any version 7.3 <= version < 8.0 where 8.0 isn’t included. see version constraint link above) is a requirement of one of your dependency packages. So you’ll need to identify which package is forcing you to stay on PHP 7 and upgrade it.If you do this one by one, you’ll probably fix one issue just to run into another. Since Laravel 10 is the latest version, a good place to start may be with the latest version of each of your dependencies. You can run
composer outdated -D
to get a list of all your dependencies, which version they are on, and the most up-to-date version that exists. I might try updating all your dependencies to the latest version and go from there (help on that in composer documentation.Once all of your packages have resolved and installed, you may start getting errors when you run your code. There’s often breaking changes from one version to the next, so reading through the upgrade guides for each previous version may be valuable.