$ composer require friendsofphp/php-cs-fixer --dev
Using version ^2.16 for friendsofphp/php-cs-fixer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.1.*"
Your requirements could not be resolved to an installable set of packages.
Problem 1
- friendsofphp/php-cs-fixer v2.16.0 requires symfony/console ^3.4.17 || ^4.1.6 -> no matching package found.
- Conclusion: don't install friendsofphp/php-cs-fixer v2.16.4
- Conclusion: don't install friendsofphp/php-cs-fixer v2.16.3
- Conclusion: don't install friendsofphp/php-cs-fixer v2.16.2
- Conclusion: remove composer/semver 3.2.0
- Installation request for friendsofphp/php-cs-fixer ^2.16 -> satisfiable by friendsofphp/php-cs-fixer[v2.16.0, v2.16.1, v2.16.2, v2.16.3, v2.16.4].
- Conclusion: don't install composer/semver 3.2.0
- friendsofphp/php-cs-fixer v2.16.1 requires composer/semver ^1.4 -> satisfiable by composer/semver[1.4.0, 1.4.1, 1.4.2, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0].
- Can only install one of: composer/semver[1.4.0, 3.2.0].
- Can only install one of: composer/semver[1.4.1, 3.2.0].
- Can only install one of: composer/semver[1.4.2, 3.2.0].
- Can only install one of: composer/semver[1.5.0, 3.2.0].
- Can only install one of: composer/semver[1.5.1, 3.2.0].
- Can only install one of: composer/semver[1.5.2, 3.2.0].
- Can only install one of: composer/semver[1.6.0, 3.2.0].
- Can only install one of: composer/semver[1.7.0, 3.2.0].
- Installation request for composer/semver (locked at 3.2.0) -> satisfiable by composer/semver[3.2.0].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.
Same here. Basically friendsofphp/php-cs-fixer doesn't support symfony/console:^5.0 yet.
Basically
friendsofphp/php-cs-fixerdoesn't supportsymfony/console:^5.0yet.
@caugner really? How did you figure this out?
The problem is with composer/semver - support for ^2 and ^3 was added and will be available with next release.
@caugner and how from that you figured the generalisation? Version 2.16.1 supports symfony/console:^5 yet you wrote:
Basically
friendsofphp/php-cs-fixerdoesn't supportsymfony/console:^5.0yet.
This is not true - not "basically", but "only in version 2.16.0"...
In the first comment we can see composer require friendsofphp/php-cs-fixer --dev which would try from latest release, not 2.16.0.
I ran that command in my project today and had the same error regarding symfony/console, hence my deduction. 🤷♂️
Great if it works now. 👍
I strongly advise not to install PHP CS Fixer as part of your project's dependencies though. PHP CS Fixer is a tool, not a library you need to build something (unless you build some library for PHP CS Fixer). You may have e.g. a dedicated tools/php-cs-fixer/composer.json file which allows you to install it without messing with your own dependencies.
Dependencies of PHP CS Fixers should remain an internal implementation detail of the tool, not something we have to keep updated for the purpose of making it installable in every Symfony app out there.
I strongly advise not to install PHP CS Fixer as part of your project's dependencies though
Yes!
and, depends, no :}
I did for this reason use the phar, so no clashes.
But, if you want to use custom rules from external packages, this approach doesn't work, see https://github.com/kubawerlos/php-cs-fixer-custom-fixers/issues/368 😢
if you want to use custom rules from external packages, this approach doesn't work
This is why I keep using Composer. I had similar issues with PhpStan and extensions. Using Composer to install each tool in its own isolated place works pretty well for me.
@caugner and how from that you figured the generalisation? Version
2.16.1supportssymfony/console:^5yet you wrote:Basically
friendsofphp/php-cs-fixerdoesn't supportsymfony/console:^5.0yet.This is not true - not "basically", but "only in version 2.16.0"...
In the first comment we can see
composer require friendsofphp/php-cs-fixer --devwhich would try from latest release, not 2.16.0.
I am not sure if that is correct. I tried installing the version 2.16.0 but that threw me the same error:
Enter the version constraint to require (or leave blank to use the latest version): 2.16.0
Search for a package:
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.1.*"
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for friendsofphp/php-cs-fixer 2.16.0 -> satisfiable by friendsofphp/php-cs-fixer[v2.16.0].
- friendsofphp/php-cs-fixer v2.16.0 requires symfony/console ^3.4.17 || ^4.1.6 -> no matching package found.
Can you try installing 2.16.4 and not 2.16.0? Or maybe more easy is to pick the constraint ^2.16