Composer not using vcs version pointing to forked repo - composer-php

I have seen this same error in other questions, but solutions offered are not fixing the issue for me.
I created a fork (and PR to master, the only branch) of this repo:
https://github.com/ipalaus/geonames/blob/master/composer.json
my fork is here:
https://github.com/jrmadsen67/geonames/blob/master/composer.json
(the change is to update the Laravel version dependencies)
In my projects, I am using:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/jrmadsen67/geonames"
}
],
"minimum-stability": "dev",
"require": {
"laravel/framework": "4.2.*",
"ipalaus/geonames": "0.2.*"
},
However, I still get the "Your requirements could not be resolved..."
"ipalaus/geonames v0.2.0 requires illuminate/database 4.1.* ->"
You can see it is looking for 4.1 laravel components, not 4.2 as my fork is telling it.
If there is other info you require, please let me know.
TIA!

What I suggest is from your current master branch checkout to a new branch. Normally bug-fix etc are assumed to be on different branch. As dev-master contains the bug fix checkout to different branch from master .
git checkout -b new-branch
git push origin new-branch
In composer.json
"repositories": [
{
"type": "vcs",
"url": "https://github.com/jrmadsen67/geonames"
}
],
"minimum-stability": "dev",
"require": {
"laravel/framework": "4.2.*",
"ipalaus/geonames": "dev-new-branch"
},
Hope that help!

Related

Why pulling package from packagist is failing?

I have forked a repository to make some changes in it. Here is my repo
https://github.com/vinsaj9/scrypt
and it has tags too. It is linked with packagist
https://packagist.org/packages/vinsaj9/scrypt
Now, I am getting following error
"The requested package vinsaj9/scrypt could not be found in any
version, there may be a typo in the package name"
when I am trying to pull it through this composer setting
{
"name": "test/test",
"description": "test",
"type": "project",
"version": "0.0.1",
"license": "OSL-3.0",
"require": {
"vinsaj9/scrypt": "*"
},
"minimum-stability": "dev",
"prefer-stable": true
}
As Hakre mentioned in his comment to my question. After uploading package to https://packagist.org/ you need to wait for some hours. In my case it was not updated even after 4 hours and reason could be that I was keep making changes in the repo, creating new releases and tags in the process of debugging my problem.

Why I can't use composer require {packageName} successfully?

I'm learn how to create Laravel packages, And I wrote a package here: noahprot/fillindata
Then I submit it to packagist
And I have set a lastest release in github
And the Packagist show like this:
Already show the latest release
Then I use Laravel CLI Tool create a new laravel project, I want try to use this package, and I use composer require noahprot/fillindata
But the result like this:
[InvalidArgumentException]
Could not find a version of package noahprot/fillindata matching your
minimum-stability (dev). Require it with an explicit version con
straint allowing its desired stability.
my package's composer.json file like this:
{
"name": "noahprot/fillindata",
"License": "MIT",
"description": "take the csv file fill into database table",
"authors": [
{
"name": "Noah Prot",
"email": "mylovewangjian#gmail.com"
}
],
"autoload": {
"psr-4": {
"NeoLee\\Fillindata\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"NoahProt\\Fillindata\\FillindataServiceProvider"
]
}
},
"require": {}
}
I make some try like:
add "minimum-stability": "dev" to composer.json, but failed,
even I edit to "stable", but failed too;
I have no idea for this situation now;
Guys, Please Help me, and give some advice, please!
Thank you everyone!
It seems that Packagist have some cache-related problems, see this issue. Mirror you're using probably have some outdated packages info. At this point you can do only two things:
Wait until packages data on mirror will be refreshed.
Report your case (see this comment).

Composer only finds latest version (tag) of Gitlab hosted package

I have created a package with some annotated tags for versioning (1.0.0, 1.0.1, 1.1.0 and 2.0.0). This package lives on own hosting (so not via Packagist)
When trying to require the package, composer only finds the 2.0.0 version and fails on any other version requirement.
Composer.php file of project using package
{
"name": "projectname",
"description": "Description.",
"keywords": ["keys"],
"license": "Licence",
"type": "project",
"require": {
...
"space/package-name": "~1.0" // Also tried 1.0.0, 1.0.*, ~1.0#dev - only 2.0.0 works
}
"repositories": [
...
{
"type": "git",
"url": "git#gitlab.com:space/package-name.git" // Make sure package is found on specific hosting
}
],
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
On running composer show "space/package-name" I get versions: * 2.0.0. So upon update, composer produces the following error:
The requested package space/package-name ~1.0 exists as name/package-
name[2.0.0, dev-master] but these are rejected by your constraint.
It looks like composer is no able to find any other version than the latest, any way of fixing this?
Things already checked:
The package does not contain a version in the composer.json (that might conflict with the git tag)
Used tags are annotated tags and are pushed to the repo.
Updates:
Might be a Gitlab - Composer issue, see this comment.
Gitlab doesn't always provide tag info when Composer tries to read the repo.
Solution: also add version info in composer.json:
{
"name": "package/name",
"version": "1.0.0",
...
}
This will be readable by composer. Careful: Git tags must match versioning info in composer.json! (might cause errors otherwise)

packagist / composer - Assign a version number

I have people using my pacakgist library.
I want to make sure that their composer.json version requirement stated as "dev-master" will not get updated when they run composer update... as I have changed the underlying architecture of the package.
How do I assign a new versioning to my new update? so that they have to explicitly say I want v1.01
I currently have the composer.json as:
{
"name": ...,
"type": "library",
"description": ...,
"keywords": ...
"homepage": ...,
"license": "MIT",
"authors": [
...
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"classmap": ["Models/"]
}
}
The composer documentation recommends specifying the version using a VCS tag. With git this looks like
git tag -a 1.0.0 -m 'Your tag message'
This will tag the HEAD of your current branch with the version 1.0.0. Then do
git push --tags
Once your package gets crawled again, the version should be available on packagist.

How to get list of all installed packages along with version in composer?

I have been working on a project using Symfony 2.1 on my local machine. I have uploaded it to my server but when I try and install the vendor bundles using Composer, I'm getting a lot of dependency errors. Presumably this is something to do with the latest version of Symfony just being released and my composer.json file not specifying exact version numbers.
Is there any way I can quickly display the version numbers of everything on my local machine?
Here is my composer.json file (which worked fine until a few days ago):
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.0.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.1.*",
"symfony/monolog-bundle": "2.1.*",
"sensio/distribution-bundle": "2.1.*",
"sensio/framework-extra-bundle": "2.1.*",
"sensio/generator-bundle": "2.1.*",
"jms/security-extra-bundle": "1.2.*",
"jms/di-extra-bundle": "1.1.*",
"sonata-project/admin-bundle": "*",
"sonata-project/cache-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"stof/doctrine-extensions-bundle": "1.1.x-dev",
"sonata-project/user-bundle": "dev-master",
"sonata-project/easy-extends-bundle": "dev-master",
"friendsofsymfony/user-bundle": "2.0.x-dev",
"friendsofsymfony/jsrouting-bundle": "*",
"liip/imagine-bundle": "*",
"simplethings/form-extra-bundle": "dev-master",
"antimattr/google-bundle": "dev-master",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"genemu/form-bundle": "2.1.*",
"behat/behat": "2.4.*#stable",
"behat/mink": "1.4.*#stable",
"behat/symfony2-extension": "*#stable",
"behat/mink-extension": "*#stable",
"behat/mink-selenium2-driver": "*#stable",
"behat/mink-browserkit-driver": "*",
"liip/functional-test-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web"
},
"config": {
"bin-dir": "bin/"
}
}
You can run composer show -i (short for --installed).
In the latest version just use composer show.
The -i options has been deprecated.
You can also use the global instalation of composer: composer global show
To list the globally installed composer packages:
composer global show -i
List installed dependencies:
Flat: composer show -i
Tree: composer show -i -t
-i short for --installed.
-t short for --tree.
ref: https://getcomposer.org/doc/03-cli.md#show
If you only want to check version for only one, you can do
composer show -- twig/twig
Note that only installed packages are shown by default now, and installed option is now deprecated.
The behaviour of this command as been modified so you don't have to pass the -i option:
[10:19:05] coil#coil:~/workspace/api$ composer show -i
You are using the deprecated option "installed".
Only installed packages are shown by default now.
The --all option can be used to show all packages.
Ivan's answer above is good:
composer global show -i
Added info: if you get a message somewhat like:
Composer could not find a composer.json file in ~/.composer
...you might have no packages installed yet. If so, you can ignore the next part of the message containing:
... please create a composer.json file ...
...as once you install a package the message will go away.
With composer-runtime-api 2.0+ there is a new InstalledVersions class with some static methods to see things programmatically.
For example:
// To list all packages (`string[]`)
\Composer\InstalledVersions::getInstalledPackages();
// To list every details of every packages
\Composer\InstalledVersions::getAllRawData();
More information: https://getcomposer.org/doc/07-runtime.md#installed-versions
If you want to install Symfony2.2, you can see the complete change in your composer.json on the Symfony blog.
Just update your file according to that and run composer update after that. That will install all new dependencies and Symfony2.2 on your project.
If you don't want to update to Symfony2.2, but have dependency errors, you should post these, so we can help you further.
Is there a way to get it via $event->getComposer()->getRepositoryManager()->getAllPackages()

Resources