问题
Explanation:
I'm unable to update symfony3 to symfony4, it throws a variety of different errors no matter what I try to do to fix them.
What I've tried:
I'm following the official documentation regarding major updates and I have ensured I have 0 deprecations.
I've updated my composer.json
as followed:
{
"...": "...",
"require": {
"symfony/symfony": "^4.0",
},
"...": "..."
}
Errors:
Your requirements could not be resolved to an installable set of packages.
Problem 1 - Conclusion: remove symfony/assetic-bundle v2.8.2 - Conclusion: don't install symfony/assetic-bundle v2.8.2 - Conclusion: don't install symfony/symfony v4.0.3 - Conclusion: don't install symfony/symfony v4.0.2 - Installation request for symfony/assetic-bundle (locked at v2.8.2, required as ^2.8) -> satisfiable by symfony/assetic-bundle[v2.8.2].
Now, I went ahead and uninstalled symfony/assetic-bundle, but it gives the same error with the following:
- "symfony/swiftmailer-bundle"
- "sensio/framework-extra-bundle"
- "sensio/distribution-bundle"
- "incenteev/composer-parameter-handler"
Then when there is nothing left to remove (pretty frustrating at this point), it just says:
Problem 1 - Conclusion: don't install symfony/symfony v4.0.3 - Conclusion: don't install symfony/symfony v4.0.2 - Conclusion: don't install symfony/symfony v4.0.1 - sensio/generator-bundle v3.1.7 requires symfony/yaml [...]
- Installation request for sensio/generator-bundle (locked at v3.1.7, required as ^3.0) -> satisfiable by sensio/generator-bundle[v3.1.7].
Question:
How do I correctly solve the errors (shown above) and how do I correctly update symfony to 4.0?
composer.json snippet:
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "^4.0",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"sensio/generator-bundle": "3.1.7",
"symfony/phpunit-bridge": "^3.0"
},
回答1:
At this stage, I created the Symfony4 skeleton and copy pasted the files from my previous project. It's a tedious task since a few things do change.
Here are a list of basic steps that may aid you in upgrading:
Follow Symfony documentation on getting rid of any deprecations that may be in your code
Create a Symfony4 skeleton
- Copy paste your specific files to their respective location.
- "Bundles" don't exist in a sense, so your directories should be something like so:
src/Controllers
,src/Services
etc. - Update your
namespaces
, by default they should beApp\Controller
,App\Services
, etc. - Database connection information is put in your
.env
file at the root directory.
Feel free to edit this post with more valuable information.
来源:https://stackoverflow.com/questions/48133458/how-to-properly-update-symfony3-3-to-symfony4-x