1
votes

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.

no 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
If you don't have yet much confident with symfony its better to upgrade before to 3.4 and then fix all the deprecations one by one, also with the help of the symfony profiler. PS: be sure that all the library/bundle version used are already compatible with 4.*gp_sflover
I have tried several times to make the jump from 3.4 to 4.0 following these instructions but have never been successful. What I do is to bring down a fresh 4.0 flex skeleton and then follow: Upgrading Existing Applications to Flex. Just copy/paste/rename stuff from your 3.4 app to the new structure. Gonna need to do this anyways as there is little point to upgrading to S4 while keeping the S3 file structure.Cerad
And if do want to keep trying your composer changes, be aware the sensio generator bundle has been replaced(basically) with a maker bundle in 4.0. symfony.com/doc/current/bundles/SymfonyMakerBundle/index.htmlCerad

1 Answers

2
votes

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:

  1. Follow Symfony documentation on getting rid of any deprecations that may be in your code

  2. Create a Symfony4 skeleton

  3. Copy paste your specific files to their respective location.
  4. "Bundles" don't exist in a sense, so your directories should be something like so: src/Controllers, src/Services etc.
  5. Update your namespaces, by default they should be App\Controller, App\Services, etc.
  6. Database connection information is put in your .env file at the root directory.

Feel free to edit this post with more valuable information.