Here's my projects composer.json:
{
"require": {
"phpseclib/phpseclib": "0.3.x"
}
}
Here's phpseclib's composer.json:
https://github.com/phpseclib/phpseclib/blob/master/composer.json
Note how that file has in it this line:
"System": "phpseclib/"
When I do cat vendor/phpseclib/phpseclib/composer.json I don't see that line. Why not?
You have told Composer to download the latest tagged version of "phpseclib/phpseclib" that matches "0.3.x".
First - there is no version tagged since they added "System": "phpseclib/" so Composer isn't downloading it. You should set the required version to be dev-master if you want to get the absolutely latest version.
Second - I don't think 0.3.x isn't a valid semver version. Did you mean 0.3.* or the equivalent ~0.3 ?
Related
If I have:
a fresh project
no composer.lock
composer.json like the following
{
"name": "fresh",
"type": "library",
"require": {
"consolidation/robo": "3.0.3"
}
}
Then run composer install
It will install consolidation/robo and update the consolidation/robo internal dependencies instead of using the consolidation/robo internal composer.lock to get a known working version of the library.
How do to get composer install to use https://github.com/consolidation/robo/blob/3.0.3/composer.lock when installing consolidation/robo dependencies instead of running the equivalent of composer update on consolidation/robo?
Currently, it's retrieving a broken internal dependency and I have to outline it in my root composer.json which internal dependency should be retrieved. Where as the https://github.com/consolidation/robo/blob/3.0.3/composer.lock has the working version of the library.
That's the way composer is supposed to work.
Lockfiles for dependencies are ignored, that's by design. If the package you are using has broken version constraints (e.g. it says its compatible with ^2.1 of foo/bar, but in reality was only tested with versions >= 2.1.0 && <= 2.2.2, and installing version 2.3 of foo/bar breaks), it's either becuse foo/bar broke the semver promise, or because the package you depend on was not adequately tested.
What you can do is simply add in your root composer.json:
{
"conflict":
"foo/bar": ">=2.3"
}
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?
The constraint that I am interested in is
"require":{ "php": "..."
Is there a way to target php 7.1 for the project packages in composer.json even though I'm running 7.2 when I call composer update/install on the command line?
You can use platform configuration from Composer: https://getcomposer.org/doc/06-config.md#platform
Basically, your composer.json would look like this:
{
"require": {
...
},
"config": {
"platform": {
"php": "7.1"
}
}
}
This will make sure that you install only packages compatible with PHP 7.1, no matter which PHP version you use to actually install the packages.
I am trying to install M2ePro module on my Magento ver. 2.1.8 application using composer and getting this error:
[http]$ php-7.0 /usr/local/bin/composer require m2e/ebay-amazon-magento2
Could not find a matching version of package m2e/ebay-amazon-magento2.
Check the package spelling, your version constraint and that the
package is available in a stability which matches your
minimum-stability (alpha).
The spelling of the package is correct, I have tried defining the version of the module (The only one available is 1.3.2):
[http]$ php-7.0 /usr/local/bin/composer require m2e/ebay-amazon-magento2:1.3.2
However get the same error so I believe stability of this module is "Beta" and I have "minimum-stability (alpha)" set so beta modules should be installed with no problems.?
I looked for solution in composer docs but could find anything about installing beta: https://getcomposer.org/doc/03-cli.md#require
Or was I looking in the wrong place?
I managed to successfully install the module on my development site and didn't receive this error so I thought it might be due to the fact that my Magento application was in the "Production" mode but setting the mode to "Developer" did not solve my problem.
UPDATE:
I just found this thread: https://magento.stackexchange.com/questions/114393/error-in-using-composer-to-install-a-module-in-magento-2-0. The answer to this question is that you need to define the package as repository. The package is from marketplace and this is content of my composer.json:
"minimum-stability": "alpha",
"prefer-stable": true,
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],
I have previously installed modules from marketplace using composer with no problems.
It came out that my auth.json had incorrect credentials and couldn't find the account.
Correcting the account settings fixed my problem.
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...