Composer package with dependencies giving me error - composer-php

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.

Related

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 :)

How not upgrade to Laravel 5.4 when I run composer update

How can I Prevent my application from upgrading to Laravel 5.4 when I run composer update.
Thanks for any assistance.
Simply edit your project's composer.json and set exact version for laravel/laravel component you want to keep, i.e.:
"require": {
"laravel/framework": "5.3.29",
...
},
Alternatively, if you want still to have automatic updates for your current version you can use * (and this is constrain which Laravel uses too):
"require": {
"laravel/framework": "5.3.*",
...
},
See docs on how Composer versions are handled.
If unsure what version of Laravel you are using now, list it with composer:
composer show laravel/*
If you want to work on dev branch of the 5.3 version you should change dependency in your Laravel's composer.json:
"require": {
...
"laravel/framework": "5.3.*#dev",
...
},
where #dev points the development feature branch of 5.3.*.
Inside your composer.json file:
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*"
- your other packages here -
},
Make sure the "laravel/framework": "5.3.*" line is set to version 5.3.* instead of 5.4.*

Composer unable to resolve requirements

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.

Composer not working try to get my own package after registering in Packagist

First some background, I'm working on a local project which I uploaded to Github and register in Packagist.
the composer is install the dependecies for development
but the problem occurs when i'm trying to catch MY OWN package after registering in Packagist
I'm getting an error
This is the command I'm using:
➜ test composer global require AA/AA:dev-master
And this is the Error:
PHP Warning: Module 'mysql' already loaded in Unknown on line 0
Changed current directory to /home/a/.composer
./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 AA/AA dev-master -> satisfiable by AA/AA
[dev-master].
- AA/AA dev-master requires hamcrest/hamcrest-php dev-master -> no matching package found.
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://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.
and this is my composer.json in GitHub:
{
"name": "AA/AA",
"description": "AA",
"require": {
"php": ">=5.4.0",
"hamcrest/hamcrest-php": "dev-master"
},
"license": "MIT",
"authors": [
{
"name": "AA",
"email": "AA#gmail.com"
}
],
"autoload": {
"psr-4": { "AA\\": "src/" }
}
}

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