Composer can't install - php

I am writing a php library and i published it on packagist but am unable to download it using composer
composer require merajsiddiqui/ibm-watson
But it throws error
[InvalidArgumentException]
Could not find package merajsiddiqui/ibm-watson at any version for your min
imum-stability (stable). Check the package spelling or your minimum-stabili
ty
Here is my repository: https://github.com/merajsiddiqui/ibm-watson
I would be thankful if you can guide me to successfully publishing so any one can download this library.

This is because your package is still in "dev" mode.
Add a tag to your repository, publish the tagged (versioned) repo.
Or add this to your composer.json:
"minimum-stability": "dev"
for example:
# composer.json
{
"name": "ProjectUsingMyIBMWatsonPackage",
"minimum-stability": "dev"
}
then run:
$ composer require merajsiddiqui/ibm-watson
Using version dev-master for merajsiddiqui/ibm-watson
(...)
- Installing merajsiddiqui/ibm-watson (dev-master f7b808d) Cloning f7b808dd97 from cache

minimum-stability: stable means that development versions of the library cannot be installed - that's the default minimum-stability setting. And for good reasons - a "dev" version changes constantly, and is thus unreliable.
You need to release an actual (non-RC, non-alpha, non-beta) version of your library for it to be considered "stable".
With Git, that means using git tag.

Go to:
https://packagist.org/
and create a package from your repo. Then it's available. Otherwise you have to add your repo in your composer configuration manually.
https://getcomposer.org/doc/05-repositories.md
The other problem is that your package is not marked es "stable" then your can't add them when your minimum stability is stable. So go to your composer.json and set them to stable.
How to mark code as stable using Composer?

Add "minimum-stability": "dev" in your composer json file or release version of your library.

Related

php composer package: problem with dev-master version

I have this problem with composer. I created one package which is connected to github. I would like to set composer to use: dev-master version of my github code, not tag. But this is what i get during installing package:
[InvalidArgumentException]
Could not find a version of package zerig/url-parser matching your minimum-stability (stable). Require it with an e
xplicit version constraint allowing its desired stability.
When i create tag on github. When i update package on composer and when i delete all versions exept one tag version, then it works. But i would like to use dev-master version. Because every change force me to do a lot of operations.
This is what i tried and think, that it will help. But Not. composer.json:
"require": {
"php" : ">=5.6.0",
"zerig/url-parser": "dev-master"
},
Thanks a lot for your help

Set composer not to auto update/upgrade packages

In npm config settings, you can disable package auto update:
npm config set save-exact=true
I don't want for packages to be auto updated/upgraded.
Is there a way to do the same in composer?
When I requre a dependency :
composer require nikic/php-parser
This:
{ "require": { "nikic/php-parser": "^4.0" }}
to be like this:
{ "require": { "nikic/php-parser": "4.0" }}
You should use composer.lock:
...running install when a composer.lock file is present resolves and
installs all dependencies that you listed in composer.json, but
Composer uses the exact versions listed in composer.lock to ensure
that the package versions are consistent for everyone working on your
project. As a result you will have all dependencies requested by your
composer.json file, but they may not all be at the very latest
available versions (some of the dependencies listed in the
composer.lock file may have released newer versions since the file was
created). This is by design, it ensures that your project does not
break because of unexpected changes in dependencies.
See more here https://getcomposer.org/doc/01-basic-usage.md#installing-with-composer-lock

How to install Composer using Composer?

EDIT: solved, I have to use "dev-master" instead of "master" or "dev".
maybe this seems weird to you... but I'm trying to locally install composer using a global composer binary.
I'm trying to write something like:
composer require composer/composer
But this doesn't work, it tells me that needs the version. Then I've tried the following variations:
composer require composer/composer=*
composer require composer/composer=master
composer require composer/composer=dev
And... nothing, I obtain the following error message:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package composer/composer 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://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.
Anyone has any idea if it's possible to do it in a "clean" way? (Allowing the following points):
specifying a very concrete version
registering it in the composer.json and composer.lock files
placing the composer binary with other php binaries like behat ...
Ok, I've made a stupid mistake. I have to use "dev-master", not "dev" nor "master".
Sorry for this dumb question.
Don't understand why do you want this, but I think #EDIT : Saw why you need this. Ok.
"repositories": [
{
"type": "vcs",
"url": "https://github.com/composer/composer.git"
}
],
"require": {
"composer/composer": "dev-master#775f6cd5c633facf2e7b99611fdcaa900b58ddb7"
}
would work.
You can view here the commit hash corresponding to different releases : https://github.com/composer/composer/releases
Well, it seems to me that you are trying to install composer using composer itself. That of course is not possible.
To install composer you need to first download it from here.
Once you have done that you will be able to install packages using the 'require' command.

Composer cannot find the package for new require within Yii2 composer.json

Ok, I'm using Yii2 and I am trying to add a new requirement/library to the project. Said library can be found here: https://github.com/cyphix333/SBBCodeParser
It is a forked project with an added composer.json.
I tried adding it as a requirement in the projects main composer file, ie:
"require": {
//..........
"samclarke/sbb-code-parser": "*"
},
Then I ran:
composer update
It just complained that it couldn't find the package or any version of it.
Then I removed that line and tried:
require samclarke/sbb-code-parser
I have the files already in my Yii vendor folder located at: #app/vendor/samclarke/sbb-code-parser
I'm pretty new to composer and am not sure what I'm doing wrong or how composer actually is supposed to know where to get the files from based on the package name.
The package samclarke/sbb-code-parser can be found at Packagist.
https://packagist.org/packages/samclarke/sbb-code-parser
By default Composer tries to resolve a stableset of packages.
But this packages doesn't provide a stable version (version tag), yet - only the dev-master version exists. Composer can not resolve it.
In order to require it, you need to lower your minimum-stability for this package to development.
You might do this for one package explicitly:
"require": {
"samclarke/sbb-code-parser": "dev-master#dev"
},
Or for all packages by setting:
"minimum-stability": "dev"
The package cyphix333/SBBCodeParser is not on Packagist.
It's a private fork. If you want exactly this code. You might add a repositories section to your composer.json and add repo with url and type with vcs there. Then Composer can load the package from the VCS repository over at Github. This is described here: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository
That would work like this:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/cyphix333/SBBCodeParser"
}
],
"require": {
"samclarke/sbb-code-parser": "dev-master"
}
}
But unfortunately, the fork is also not well maintained and doesn't contain a valid composer.json file.
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of https://github.com/cyphix333/SBBCodeParser, could not load a package from it.
This needs to be fixed first....

Composer + twitter bootstrap 2

How I can add this repo https://github.com/twbs/bootstrap-sass/tree/2.1-stable to my composer.json?
I tryed this:
"minimum-stability": "dev",
"require-dev": {
"twbs/bootstrap-sass": "dev-2.1-stable"
}
but got error:
The requested package twbs/bootstrap-sass could not be found in any version, there may be a typo in the package name
dev-2.1-stable isnt in the package:
https://packagist.org/packages/twbs/bootstrap-sass
its a branch in their git repo, but they havent submitted those versions to packagist (or the tags they have given on the branches arent valid for packagist to pick them up on its own: https://packagist.org/about)
I am assuming you know they have a version 3 available. Also, do you not have Ruby gems installed? To install using their instructions add the package to your Gemfile, not to composer.
If you do want to install via composer, it has to be a composer package, which from https://packagist.org/packages/twbs/bootstrap-sass looks like only version 3 and up are available.
Try using:
"require-dev": {
"twbs/bootstrap-sass": "3.2.*"
}
Notice the 3 above, I tried 2.1.* and it couldn't be found. 3.2.* worked fine.
Also, incase you're wondering the * just means 'latest'. If you want 2.1 you might have to do it via Ruby Gems.

Categories