Error installing composer due to symfony/routing version

In Ubuntu 18.04, I have php installed. I confirmed it work with index.php testing. I now try to install composer

composer install

But below error was shown:

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/routing v4.1.6 -> satisfiable by symfony/routing[v4.1.6].
    - don't install symfony/symfony v3.4.17|don't install symfony/routing v4.1.6
    - Installation request for symfony/symfony v3.4.17 -> satisfiable by symfony/symfony[v3.4.17].

I have previously install Symfony as a package by

 sudo apt install php-symfony
php-symfony is already the newest version (3.4.6+dfsg-1ubuntu0.1).

Do I uninstall symfony and replace it with symfony/routing v4.1.6? I googled for a long time but I cannot find relevant instructions. Symfony documentation appears to only show instruction on using composer to install Symfony. But I now have trouble to install composer. Please help, thanks!


2 Answers Error installing composer due to symfony/routing version

If you want to install a new Symfony project, I recommend not using the packaged php-symfony and instead use composer to create a new project from scratch. I don't know much about the package, but as you can tell from the version it is outdated (v3.4.18 is the current version). Relying on an outdated package is not recommended. Instead use the recommended way to set up a new project:

composer create-project symfony/skeleton my-project

If you want a full stack application you can also use symfony/website-skeleton as the basis for the project. If you want to stick to the old 3.4 version you can add the constraint to the command:

composer create-project symfony/skeleton:"^3.4"

See also

4 months ago

The symfony/symfony package already includes the Routing component (which you try to install with the symfony/routing package). This is something Composer wrongly allowed in older versions and was fixed in Composer 1.7.3.

Do you really need the Routing component in version 4? If that's the case, you need to remove symfony/symfony first and require all the needed components explicitly if you cannot upgrade all Symfony packages to 4.1.

4 months ago