I can't flag my composer development as stable - composer-php

I'm developing my first composer package as a test, and everything is ok, except that I didn't manage to flag my code as stable.
When requiring my code, if my composer.json file does not have a "minimim-stability": "dev", I've got this error message :
Your requirements could not be resolved to an installable set of packages.
I've already read this answer, and I created a 1.0.0 Tag, but it does not change anything.
Could someone explain what I've missed ?

Okay, its works now, maybe I was too impatient.

Related

composer require conflict with symfony/yaml [duplicate]

I did a lot of research on the web, but did not find a documentation of the composer error log. In the discussions I found, nobody had an explanation that was consistent with the error log. For example:
[Support] Need explanation for "Conclusion: don't install ..."
Why composer says "Conclusion: don't install" when (seemingly) no obstacles are present?
I know, what composer does and can resolve issues on my own, but I often have to consult packagist.org for this. Despite being quite (and unnecessarily) verbose, the composer log only gives me some hints. It does not really point out the concrete problems.
Does anyone know of a complete documentation or how to explain the reasoning behind the logs, maybe taking the above ones as an example?
Documentation of Composer can be found at getcomposer.org/doc, especially Troubleshooting section. Usually the dependency problems comes from misconfiguration of your composer.json and understanding Composer logs comes with experience or learning on trial and error. Documenting every possible errors out of hundreds can become quickly outdated. If you believe some specific error isn't clear enough, you can always raise a new suggestion at the Composer's GitHub page.
As suggested in linked GitHub issue, "Conclusion: don't install" message it could be related to requirements defined in minimum-stability. Another linked question could be related to Composer's bug as reported at GH-7215.
Errors
Here is a small guide explaining the common Composer's errors:
Can only install one of: org/package[x.y.z, X.Y.Z].
If you see this messages, that could be the main cause of the dependency issue. It basically means that based on the Composer's dependency calculation both of these versions are required, but only one major version can be installed (you cannot have both x.y.z and X.Y.Z, unless you split your configuration for different folders). To see why these packages are required, use the composer why/depends command and adjust the dependencies accordingly.
See: How to resolve a "Can only install one of:" conflict? & How to solve two packages requirements conflicts when running composer install?
Installation request for org/package2 (locked at vX.Y.Z)
This message means that there was an installation request for org/package, however, it is locked at X.Y.Z. If the requested version is not compatible with the locked version (like a different major version), you cannot install both. This message often comes along with already mentioned "Can only install one" one. So, whenever you see "locked at", that means Composer reads your installed package version from the composer.lock file. To troubleshoot, you can use composer why/depends command to find why the package was requested and adjust the compatibility, otherwise, you may try to remove composer.lock file and start from scratch (ideally from the empty folder).
See: Installation failed for laravel/lumen-installer: guzzlehttp/guzzle locked at 6.3.0
org/package1 vx.y.z conflicts with org/package2[vX.Y.Z].
It is a similar issue as above where two packages are conflicting and you need to solve the dependency manually. Reading the whole context of the message may give you some more clues. Checking the dependency tree may also help (composer show -t).
conflict with your requirements or minimum-stability
This message means as it reads, so you should check the required version and/or your minimum-stability settings.
This can be caused by a package being marked as non-stable and your requirements being "stable only. See: But these conflict with your requirements or minimum-stability
Or because of conflicts with other installed packages. See: How to identify what is preventing Composer from installing latest version of a package?.
For any other errors, check out the official Composer's Troubleshooting page.
Troubleshooting
Here are more suggestions how to troubleshoot the Composer dependency issues in general:
Add -v/-vv/-vvv parameter to your command for more verbose output.
Run composer diagnose to check for common errors to help debugging problems.
If you seeing "locked at x.y.z" messages, it relates to packages locked in your composer.lock.
Test your composer.json on the empty folder.
Keep your composer.json to minimum.
Run composer show -t to see your current dependency tree.
Run composer show -a org/package x.y.z to check the details about the package.
Feel free to ask a new question at Stack Overflow.
To fully debug Composer's dependency problem, you can:
Analyse or modify the source code (e.g. DependencyResolver/Problem.php).
Run Composer under XDebug, either by the breakpoint or generating a full or partial trace file.
Useful threads explaining common errors:
How to resolve a "Can only install one of:" conflict?
composer.json fails to resolve installable set of package
Discover latest versions of Composer packages when dependencies are locked
When trying to install php-jwt facing trouble with auth0
Reference - Composer error "Your PHP version does not satisfy requirements" after upgrading PHP
How to identify what is preventing Composer from installing latest version of a package?
Error:
somevendor/somepackage[v1.0.0, ..., v1.9.1] require composer-plugin-api ~[X.X]
This means that that somevendor/somepacakge requires that a specific version range of Composer to be installed.
Run composer -v and compare it to the version constraint in the error message (shown as ~X.X in the example above, but that could be something like ^1.0, or ^2.2, etc).
If your version does not match the constraint, see if you can either:
upgrade or downgrade your composer version to match the composer constraint in the error message
upgrade somevendor/somepackage so that it can work with your Composer version.

Error when changing PHP version on Heroku app

As some of you might know, PHP version ≥7.2 has an issue regarding count: count(): parameter must be an array or an object that implements Countable and this does contributes to a lot of problems.
I'm using the PHP framework Laravel 5.3 on Heroku, which until the change of PHP version worked perfectly fine. So why don't I just change the PHP version? Well, according to the docs I'm supposed to just change the version in my composer.json, run composer update and everything will be fine but no - I'm getting this error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- This package requires php ^5.6.4 but your PHP version (7.2.1) does not satisfy that requirement.
Anyone knowing anything that can contribute solving my problem?
You also need to push composer.lock.
Change the version in your local and make $ composer update.
Make sure you have changed composer.lock.
Push both files on Heroku.
From the documentation, https://devcenter.heroku.com/articles/php-support#php-runtimes
Next, ensure that your new requirements are “frozen” to composer.lock
by running:
$ composer update
Finally, don’t forget to git add and git commit both files!
Hope this helps.

Composer, set minimum download stability

i am pretty new with composer and i am having a problem with a download.
I install composer and afterwards i want to install a proyect in beta state trough this command:
composer require google/apiclient:^2.0.0#RC
(This would download the google api client libraries with all their dependencies configurated).
I receive an error telling me that the package is not available in a stable-enough version for my minimum stability settings.
I have read a lot comments from people regarding this issue, but it always involves a composer.JSON file in a local project (not an external download from step 1).
My question is, how could i dowload that project? I would first have to set the minimum stability of composer to "dev" instead of "stable", but how can i do this?
This is what I get:
The windows command shell requires to enclose the package and version into double quotes (and it isn't a bad idea in Linux as well):
Doesn't work in Windows:
composer require google/apiclient:^2.0.0#RC
Does work:
composer require "google/apiclient:^2.0.0#RC"
Please don't set "minimum-stability" to "dev", because this is a global setting and will instantly install development versions that you probably don't want, because they are no final release and may be unstable. This would be true for ALL packages you require, and their dependencies.
SOLUTION: I finally solved it this way:
First you need to create an empty composer.json file wherever you want.
Afterwards you do something like this (or literally this, in my case):
{
"name": "Your title",
"minimum-stability": "dev",
"require":
{
"google/apiclient": "2.0.*"
}
}
Afterwards you go to the directory with this file in the cmd (windows console) and type "composer install".
This will solve the problem and install all the libraries with its dependencies. It is not the same as setting the minimum stability to "dev" for all libraries, but it will solve the problem for specific packages.

Composer is not updating package to newest version

tl;dr: I'm having troubles forcing Composer to get latest changes to my local package. It seems, that problem is caused by latest change not being part of any release in packages repository.
I'm using yii2-language-picker in my project and have added it with instructions given in docs:
php composer.phar require --prefer-dist lajax/yii2-language-picker "1.*"
Recently extension's author has made a change. However, this change is not part of any release, because it is 1 commit after latest release. If I'm not mistaken (I'm quite new to Composer), this causes Composer to not update my local package -- after composer update or composer install I'm getting Nothing to install or update.
Because that latest change is not a part of any relase, I was suggested to edit composer.json file, change "lajax/yii2-language-picker": "1.*" in required section to "lajax/yii2-language-picker": "*" and issue another composer update.
I have also completely removed this package and installed it again with both "1.*" and "**".
None of these brought any effects. Composer still claims, that there is nothing to install or update.
What can be causing this situation? Is there anything I can do in this case, or the only option I'm left with is to sit down and wait until package / repository author will make that change part of another release?
I tried to manually update this package, but after composer status I'm getting No local changes and I'm woried, that all these changes will be lost, once actual package update will be released. Should I make any local changes in this situation or should I sit and wait?
Changing 1.* to dev-master probably solves your problem.

Composer: how to install `dev` packages in Symfony 2.3?

Trying to install the KnpGaufretteBundle in a Symfony 2.3 project, I'm having no luck. The problem is:
minimum-stability:stable (in composer.json);
the bundle I require is dev-master version still.
Reading this in the Symfony docs was frustrating:
If you know of a cool bundle or PHP library that still requires a dev
minimum stability, talk to the lead developer and convince him to tag
a stable release.
I'm not changing the minimum stability of the whole project to dev, as it would certainly make a huge mess - I mean, can't I use stable packages and dev packages side by side?
Am I missing something about composer maybe?
Edit (14 August 2013)
According to Sven's answer below, I've edited my composer.json (you can find it here) and it started to work. Anyway, this is a partial solution, because inline aliases do not work for dependencies - so in my case I'd have to specify all dependencies of "less-than-stable" packages first, and alias them one by one.
just use
"knplabs/knp-gaufrette-bundle": "dev-master#dev"
if you need the latest dev version
you can also change minimum-stability to dev and add "prefer-stable": true like this:
"minimum-stability": "dev",
"prefer-stable": true,
then composer will always try to find a stable version and if nothing found install dev, so your symfony packages will be still stable.
But in your case composer will install v0.1.4 (latest stable of knplabs/knp-gaufrette-bundle), so you need dev-master#dev anyway. prefer-stable is just a hint for you.
Have a look at aliases: http://getcomposer.org/doc/articles/aliases.md
They are supposed to allow you to address a branch (which by definition is always in development, because you can only access the latest commit) in a way that that branch should be the logical extension of a version tag.
For a yet untagged project, a proper assumed tag version would be like "0.0.0".
You should try the inline alias for the bundle.

Resources