Required package in composer.json not found - laravel

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

Related

PHP Composer require dependency if *condition*

Is there any way to require a dependency in composer.json only if a condition is fulfilled?
Typically, I'd like to use Guzzle 6 if the PHP version is high enough, otherwise do nothing. The library will handle a fallback if you don't have guzzle.
I know you can use "some/dependency": "^1.0 || ^2.0", which will choose the latest major that fits your other requirements. What I'm looking for is something like:
"some/dependency": "nothing || ^2.0"
You cannot do this directly as constraints in your composer.json. However you can achieve this by creating bridge package, which may define different dependencies for different versions, which could have different requirements.
So you can create me/guzzle-wrapper package and:
Tag 1.0.0 version with composer.json:
{
"name": "me/guzzle-wrapper",
"require": {
"php": "<5.5",
}
}
Tag 2.0.0 version with composer.json:
{
"name": "me/guzzle-wrapper",
"require": {
"php": ">=5.5",
"guzzlehttp/guzzle": "^6.3"
}
}
So instead requiring guzzlehttp/guzzle directly, you can use this meta package - depending on your PHP version Composer will install 2.0.0 which requires Guzzle, or 1.0.0 which does not require anything.
But if your package is able to work without Guzzle, maybe you should move this requirement to suggest section?

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.

Why I cannot install my composer new package?

The package - https://packagist.org/packages/drakonli/php-utils
My composer:
{
"require": {
"php": ">=5.3.0",
"drakonli/php-utils": "dev-master"
},
"minimum-stability": "dev"
}
The error I get when i use "composer install"
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package drakonli/php-utils could not be found in any version, there may be a typo in the package name.
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.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
I have added a tag to this package, so it should not be the problem with stability of version.
What I also tried - I tried to search for my package on packagist AND using command composer search. And this is what I got:
When I try to search for "drakonli/" - I CAN find my package, but when I try to search for "drakonli/php-utils" or "php-utils" I CAN'T find my package.
Help, pls.
UPDATE
I was wrong - the package is found but it's on the 1608 page after packages that don't even have "php" or anything in it's name. Even when using the package full name.
UPDATE #2
composer search drakonli
result:
drakonli/php-utils PHP lib of different utility interfaces/classes
AND
composer info drakonli/php-utils
result:
[InvalidArgumentException]
Package drakonli/php-utils not found
Losing my mind here :D
After about 12 hours it fixed on it's own...

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/" }
}
}

Resources