Composer unable to resolve requirements - composer-php

When you look at log, you can see this, which doesn't make any sense:
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- meridius/coding-standard 1.0.0 requires consistence/coding-standard ^0.10.1 -> satisfiable by consistence/coding-standard[0.10.1].
- meridius/coding-standard 1.0.1 requires consistence/coding-standard ^0.10.1 -> satisfiable by consistence/coding-standard[0.10.1].
- Conclusion: don't install consistence/coding-standard 0.10.1
- Installation request for meridius/coding-standard * -> satisfiable by meridius/coding-standard[1.0.0, 1.0.1].
The project I am trying to build has "squizlabs/php_codesniffer": "^2.5" and "meridius/coding-standard": "^1" as requirements. The update passes fine in these cases:
if I remove either of mentioned requirements, clear vendor and update
if I remove either of mentioned requirements, clear vendor, update and add the removed requirement back again and do update
I don't understand why the second case works but when both packages are required it does not.
The culprit seems to be squizlabs/php_codesniffer which is required by consistence/coding-standard and straight in the project I am building.
If I do composer show -t | grep -C4 squizlabs/php_codesniffer I can see that squizlabs/php_codesniffer is required several times but all the version constraints seem fine to me.
You can see the composer.json here.

Seems to be a bug in Composer.
This works:
"require-dev": {
"meridius/coding-standard": "*",
"squizlabs/php_codesniffer": "^2.5"
},
This doesn't work:
"require-dev": {
"squizlabs/php_codesniffer": "^2.5",
"meridius/coding-standard": "*"
},
As far as I know Composer the order of requirements should not matter (someone might confirm this). Report it as a bug.

Related

php 8.2 + laravel 9 failed with composer error that cron-expression does not match the constraint

I am updating laravel to use php 8.2, according to laravel document here, using "laravel/framework": "^9.43" should be enough.
My composer.json are the following,
"require": {
"php": "^8.2",
"clue/socket-raw": "^1.3",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"gregwar/captcha": "1.*",
"guzzlehttp/guzzle": "^7.0.1",
"itsgoingd/clockwork": "^5.1",
"jacobcyl/ali-oss-storage": "^2.0",
"james-heinrich/getid3": "^1.9",
"laravel/framework": "^9.43",
"laravel/horizon": "^5.7",
"laravel/tinker": "^2.5",
"php-curl-class/php-curl-class": "^8.6"
},
But when running composer install --no-scripts --no-autoloader --no-dev (I don't use composer.lock here), composer complained,
laravel/framework[v9.43.0, ..., 9.x-dev] require dragonmantank/cron-expression ^3.3.2 -> found
dragonmantank/cron-expression[dev-set-up-semaphore,
dev-update-v3-php8, dev-master, dev-issue/35-fix-and-or-problem,
dev-allow-phpstan-failures, v1.0.0, ..., v1.2.1, v2.0.0, ...,
v2.3.1.x-dev, v3.0.0, ..., v3.3.1] but it does not match the
constraint.
I know laravel/framework 9 requires cron-expression ^3.3.2 as https://packagist.org/packages/laravel/framework said. But I can't figure out which other package requires a different version of cron-expression. I search the old composer.lock (which I don't use when install) I find multi-mention of dev-master, but no [dev-set-up-semaphore, dev-update-v3-php8, dev-issue/35-fix-and-or-problem, dev-allow-phpstan-failures]
Please check the following build log
How do I find that package ? BTW, php 8.1.7 + "laravel/framework" 8 works fine.
--- update ---
I find the reason why composer complains.
I have "require-dev" in my composer and all packages in it use the latest versions! I also check https://packagist.org/ to make sure they all say they support ^8.0. Besides, my command is composer install --no-scripts --no-autoloader --no-dev, no-dev !
So I didn't expect "require-dev" will cause problem. But only after I remove the "require-dev" did composer run successfully!
Apparently one of those packages do not support php 8.2 yet.
"require-dev": {
"facade/ignition": "^2.17",
"fakerphp/faker": "^1.21.0",
"laravel/sail": "^1.18.1",
"mockery/mockery": "^1.5.1",
"nunomaduro/collision": "^6.4",
"phpunit/phpunit": "^9.5.28"
}
After removing "facade/ignition" from "require-dev", composer finally works!
As for why does "facade/ignition" cause the problem and what is the solution for it, please refer to #NicoHaase's answer and my discussion with him.
"Apparently one of those packages do not support php 8.2 yet." - no, that's not the cause. Ignition does not support Laravel v9, as written in their readme:
If you're on Laravel 8 or above, you can switch to spatie/laravel-ignition, which is a drop-in replacement. Replace facade/ignition with "spatie/laravel-ignition": "^1.0" in your application's composer.json file.
Going forward, we'll only add security fixes to facade/ignition and highly encourage you to switch to spatie/laravel-ignition.
Use composer's why-not command:
composer why-not laravel/framework 9.43

Laravel Shibboleth package

How to set up and use laravel shibboleth package,
supposing that in my organization there are distinct user roles? My version of Laravel Framework is 5.7.26. I initially tried to install it (with composer require razorbacks/laravel-shibboleth via cmd) with no success.
Below is the result of my attempt to install it. Any idea?
" Problem 1
- Installation request for razorbacks/laravel-shibboleth ^3.0
-> satisfiable by razorbacks/laravel-shibboleth[3.0.0].
- Conclusion: remove laravel/framework v5.7.26
- Conclusion: don't install laravel/framework v5.7.26
- razorbacks/laravel-shibboleth 3.0.0 requires laravel/framework 5.4.* || 5.5.*
-> satisfiable by laravel/framework[5.4.x-dev, 5.5.x-dev].
- Can only install one of: laravel/framework[5.4.x-dev, v5.7.26].
- Can only install one of: laravel/framework[5.5.x-dev, v5.7.26].
- Installation request for laravel/framework (locked at v5.7.26, required as 5.7.*)
-> satisfiable by laravel/framework[v5.7.26].
Installation failed, reverting ./composer.json to its original content."
Depending on your project it might be easiest to downgrade your Laravel framework version to 5.5. You'll see on the razorbacks/laravel-shibboleth packagist page that it requires Laravel 5.4 or 5.5. On the package's github profile you'll see that there's an issue logged for Laravel 5.6 support and that the latest commit was on 25 Jan 2018, so it is not very up to date. I recommend always checking these things before deciding on using a package.
To downgrade to Laravel 5.5, you'll need to change your composer.json file to to require "laravel/framework": "5.5.*". You'll also need to check that all your other dependencies are compatible with 5.5. If they are not, you'll also need to downgrade them to compatible versions.
Lastly, consider using uabookstores/laravel-shibboleth or prasad/laravel-shibboleth which are forks of razorbacks/laravel-shibboleth that have Laravel 5.7 support.
You can downgrade laravel. Or you can fork shibboleth, change the composer.json requirements/limits, then start testing to see if the package works with 5.7
fork this into your github account https://github.com/razorbacks/laravel-shibboleth
clone your new forked copy to local work machine
edit composer.json to adjust limits/requirements
commit and push back to your forked copy
Now, in your project that uses the package you'll need to point to your copy/fork instead of the original public version of the package.
add your fork to the "repositories" section of composer.json (NOT the same composer.json ... this is the laravel project composer.json)
run composer update
Your new repositories section in the composer.json file should look something like this...
"repositories": [
{
"type": "vcs",
"url": "https://github.com/YOUR-ACCOUNT-NAME/laravel-shibboleth"
}]

Cant install blocktrail/blocktrail-sdk with composer on laravel project

The problem is
I require blocktrail/blocktrail-sdk with composer on my laravel project and get these errors
Using version ^3.2 for blocktrail/blocktrail-sdk
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for paragonie/random_compat (locked at v9.99.99) -> satisfiable by paragonie/random_compat[v9.99.99].
- blocktrail/blocktrail-sdk v3.2.0 requires bitwasp/bitcoin v0.0.34.1 -> satisfiable by bitwasp/bitcoin[v0.0.34.1].
- blocktrail/blocktrail-sdk v3.2.1 requires bitwasp/bitcoin v0.0.34.1 -> satisfiable by bitwasp/bitcoin[v0.0.34.1].
- blocktrail/blocktrail-sdk v3.2.2 requires bitwasp/bitcoin v0.0.34.1 -> satisfiable by bitwasp/bitcoin[v0.0.34.1].
- Conclusion: don't install bitwasp/bitcoin v0.0.34.1
- Installation request for blocktrail/blocktrail-sdk ^3.2 -> satisfiable by blocktrail/blocktrail-sdk[v3.2.0, v3.2.1, v3.2.2].
Installation failed, reverting ./composer.json to its original content.
COMPOSER.JSON require and require-dev contents
"require": {
"php": "^7.1.3",
"bitwasp/bitcoin": "^0.0.34.1",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.0",
"laravel/framework": "5.7.*",
"laravel/socialite": "^3.1",
"laravel/tinker": "^1.0",
"paragonie/random_compat": "^2.0.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
What can I do ? I tried everything , no point
linux debian 8, php 7.2.9, laravel 5.7.5, thanks *
You need to redo some work here because it's a mess in dependencies where versions require symfony 3 and 4 at the same time (which will generate a conflict, that is not obvoius from the message you're getting right now). Same goes for deps for php 5.6 and 7.1 which are not fully compatible.
blocktrail-sdk-php already requires bitwasp/bitcoin, no need to add it in your own composer.json
https://github.com/blocktrail/blocktrail-sdk-php/blob/master/composer.json#L36
blocktrail-sdk-php also requires 99designs/http-signatures-guzzlehttp
which requires
"symfony/http-foundation": "~2.8|~3.0",
and then, you are requiring a newer http-foundation ("^4.1") in another package, specifically laravel-framework (check composer.lock)
I think your best option is to review what you actually want, review composer.json and create it again from scratch starting from the most important package.
Please start from the most important package, and match the versions to it starting from there. You'll have to review composer.json "require" node for every dependency package you need, and sometimes use some older package release (some of them are already made for symfony 4.X while some of your requirements can only handle 3.X). On github, you can easily switch to older revisions via dropdown on the top when you review composer.json to older version until the "require" matches your own dependency versions.
Please be aware you might have to prepare forks of the specific repos to make the adjustments.
If you're doing an update, remember to submit a PR with the package update, so programmers later don't have to fight the same thing :)

Composer package with dependencies giving me error

I don't understand why this error is occurring as each project is published on packagist using only master:
composer.json of second project
{
"type": "symfony-bundle",
"license": "MIT",
"require": {
"php": "^7.1.3",
"vendor/project1": "dev-master"
}
}
Here is the error I am getting:
Problem 1
- Installation request for VENDOR/PROJECT2 dev-master -> satisfiable by VENDOR/PROJECT2[dev-master].
- VENDOR/PROJECT2 dev-master requires VENDOR/PROJECT1 dev-master -> satisfiable by VENDOR/PROJECT1[dev-master] but these conflict with your requirements or minimum-stability.
What am I missing?
This is related to minimum-stability settings. By default this is set to stable, which will not allow installing unstable package unless you explicitly declare that you want it. You may fix this in 2 ways:
Allow to install unstable dependencies. Add this to your composer.json:
"minimum-stability": "dev",
"prefer-stable": true,
prefer-stable ensures that you will get stable package if it exist - without this setting Composer will install everything from dev branches, and you probably don't want this.
Explicitly require package in unstable version:
"require": {
...
"VENDOR/PROJECT1": "dev-master"
},
Both solutions works only if you do this in composer.json of your main app.

Required package in composer.json not found

I have created using the workbench of Laravel a package and uploded it to Packagist under pica/pica-base. The package contains the following require statement:
"require": {
"php": ">=5.4.0",
"illuminate/support": "4.2.*",
"gregwar/captcha": "dev-master"
},
When I try to install my pica/pica-base package it fails stating the following error message:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- pica/pica-base dev-master requires gregwar/captcha dev-master -> no matching package found.
- pica/pica-base dev-master requires gregwar/captcha dev-master -> no matching package found.
- Installation request for pica/pica-base dev-master -> satisfiable by pica/pica-base[dev-master].
On advice of the FAQ I also tried the procedure with 'dev'in staed of 'dev-master'with the gregwar/captcha package but with the same result.
I don't understand this because with the exact same requirement I can install the gregwar-package in any other project. And the link to the package shows up in the page of my package on Packigist (https://packagist.org/packages/pica/pica-base).
So why does this fail?
Thanks for efforts!
By default, Composer uses only stable packages when calculating your dependencies. There are two ways to override this if you want to use an unstable (dev-master) package:
In your root composer.json, require a dev-master version of a package (this is why you have no problem getting the pica/pica-base package, as it is in your root composer.json)
In your root composer.json, set the minimum-stability flag to dev:
"require": {
...
},
"minimum-stability": "dev"
So you can basically do one of the following things:
Add the gregwar/captcha dependency in your root composer.json (the one of your Laravel project)
Add "minimum-stability": "dev" to your root composer.json.
I recommend going for the second option. If you do so, you might want to also add the prefer-stable flag, in order to make sure that not all packages are downloaded in unstable versions:
"require": {
...
"pica/pica-base": "dev-master"
},
"minimum-stability": "dev",
"prefer-stable": true

Resources