Composer: no matching package found - php

I create a widget that is under development. The problem is that when I run:
composer require chofoteddy/yii2-bootstrap-wizard "*"
I get the following message:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for chofoteddy/yii2-bootstrap-wizard * -> satisfiable by chofoteddy/yii2-bootstrap-wizard[dev-master].
- chofoteddy/yii2-bootstrap-wizard dev-master requires vinceg/twitter-bootstrap-wizard * -> 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 <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.
What I seek is to add https://github.com/VinceG/twitter-bootstrap-wizard.git repository as a dependency of my project. "VinceG/twitter-bootstrap-wizard" is not registered in "Packagist".
I modified many times my composer.json file, in order to correct it, but I can not make it work.
My file composer.json:
{
"name": "chofoteddy/yii2-bootstrap-wizard",
"description": "Wizard form based on twitter bootstrap plugin (#VinceG)",
"homepage": "https://github.com/Chofoteddy/yii2-bootstrap-wizard",
"keywords": [
"yii2",
"wizard",
"bootstrap",
"yii2-extension"
],
"type": "yii2-extension",
"version": "0.1",
"license": "MIT",
"authors": [
{
"name": "Christopher",
"email": "chofoteddy88#yahoo.com.mx"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"VinceG/twitter-bootstrap-wizard": "*"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/VinceG/twitter-bootstrap-wizard"
}
],
"autoload": {
"psr-4": {
"chofoteddy\\wizard\\": ""
}
}
}
Composer information:
sudo composer self-update
You are already using composer version b2173d28fc8b56236eddc8aa10dcda61471633ec.

Because VinceG/twitter-bootstrap-wizard is not a Composer package (it does not include a composer.json) you have to define this in your composer.json
Your repository section should look like this:
"repositories": [
{
"type": "package",
"package": {
"name": "VinceG/twitter-bootstrap-wizard",
"version": "1.2",
"dist": {
"url": "https://github.com/VinceG/twitter-bootstrap-wizard/archive/1.2.zip",
"type": "zip"
},
"source": {
"url": "https://github.com/VinceG/twitter-bootstrap-wizard.git",
"type": "git",
"reference": "1.2"
}
}
}
],
You might also have a look at component-installer and the composer-asset-plugin to manage components and bower packages within composer.

The problem is probably the minimum-stability defined in your project root composer.json (or if not defined it defaults to stable)
As the bower repository has no release yet you should:
"VinceG/twitter-bootstrap-wizard": "#dev"
define minimum-stability: "#dev"
Please note that if you use this package from a different project you need to either define minimum-stability: "#dev" in that project or define the
"VinceG/twitter-bootstrap-wizard": "#dev" in root composer.json
There's also an option in composer which lets you specify: "prefer-stable"
More info on this:
https://igor.io/2013/02/07/composer-stability-flags.html

Related

Composer Path Repositories without a package manager

Since composer merge plugin is deprecated and the alternative is use of composer path repositories I found a problem transitioning to the later.
My structure is:
/composer.json
/local/composer.json
Where /composer.json is main composer with all setup and /local/composer.json is a file managing only private repositories.
Contents of each file are:
#/composer.json
{
"name": "main/project",
"type": "project",
"repositories": [
{
"type": "path",
"url": "local"
}
],
"require": {
"sub/project": "dev-main"
},
"extra": {
"installer-paths": {
"web/modules/custom/{$name}": [
"type:drupal-custom-module"
]
}
}
}
#/local/composer.json
{
"name": "sub/project",
"autoload": {},
"repositories": {
"test_repo": {
"type": "git",
"url": "git#github.com:rotari/test_repo.git"
}
},
"require": {
"rotari/test_repo": "dev-main"
}
}
As you can see the plan is simple: main composer requires sub/project and sub/project requires rotari/test_repo. However on install I'm prompted with error
sub/project dev-main requires rotari/test_repo dev-main -> could not be found in any version
Running composer install in /local is a success so there is no problem accessing rotari/test_repo.
Any idea or suggestions how this issue could be solved?
This part from documentation answers my quetion:
https://getcomposer.org/doc/faqs/why-cant-composer-load-repositories-recursively.md
Composer in not able to load repositories recursively.

Unable to search and require private composer package at packagist

I have created a private package at packagist.org under new organisation. Here are the steps i took so far:
Developed a lumen package at local instance.
Configured composer.json to be used with private composer package.
Pushed the local package to private github repo.
Added the package by URL at packagist.org and all the api token and credentials has also been setup.
The project get added without any error.
I have added the composer global auth token to require private package.
When i either search or require the package to new lumen instance i get the error
[InvalidArgumentException]
Could not find a matching version of package grv/contentfeed. Check the pac
kage spelling, your version constraint and that the package is available in
a stability which matches your minimum-stability (dev).
This is how my composer.json looks like:
{
"name": "grv/contentfeed",
"description": "This is yet another Lumen composer package wrapper",
"type": "elx-core-plugin",
"version": "1.2.3",
"keywords": ["demo","lumen","drupal"],
"homepage": "https://github.com/gauravmehrasrijan/elx-feed",
"require": {
"composer/installers": "^1.0.24"
},
"autoload": {
"psr-4": {
"Grv\\Contentfeed\\": "/src"
}
},
"license": "MIT",
"minimum-stability": "dev",
"extra": {
"laravel": {
"providers": [
"Grv\\Contentfeed\\ContentFeedServiceProvider"
]
}
},
"authors": [
{
"name": "Gaurav Mehra",
"email": "gauravmehra1987#gmail.com"
}
],
"repositories": [
{"type": "composer", "url": "https://repo.packagist.com/grvatsrijan/"},
{"packagist.org": false}
]
}
Are there some more steps to it that i am missing. I have even tried creating new packages with different namespace but no success.
It turned out that i was adding this piece of code at wrong place.
"repositories": [
{"type": "composer", "url": "https://repo.packagist.com/grvatsrijan/"},
{"packagist.org": false}
]
Instead of adding it to created composer package, this will need to go in the consumer composer package( where i am trying to require this package ).
Adding "repositories" key to composer.json will allow composer to search for private package within the https://repo.packagist.com/grvatsrijan/

Composer does not respect installer-paths

Here is the scenario:
I have two projects driven by composer. The first one looks like this:
{
"name": "myusername/composer_test",
"description": "Composer project for CircleK Drupal 8",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Name Surname",
"role": "webdeveloper"
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"php": ">=5.6",
"composer/installers": "^1.2",
"drupal-composer/drupal-scaffold": "^2.5",
"drupal/core": "^8.7.0",
"vlucas/phpdotenv": "^2.4",
"webflo/drupal-finder": "^1.0.0",
"webmozart/path-util": "^2.3",
"zaporylie/composer-drupal-optimizations": "^1.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"installer-paths": {
"web/core": ["type:drupal-core"]
}
}
}
Second one requires the first one and it's pretty straight forward:
{
"name": "user/site",
"description": "Composer for Site",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Name Surname",
"role": "webdeveloper"
}
],
"repositories": [
{
"type": "git",
"url": "git#github.com:myusername/composer_test.git"
},
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"myusername/composer_test": "dev-drupal_only"
},
"minimum-stability": "dev",
"prefer-stable": true
}
As you can see the first one defines where drupal core should be placed at by defining installer-paths. It turns out that when I run composer install just for the first composer.json file drupal core ends up in ./web directory as should, however when I run composer install for second file it does download every package from first composer.json just fine, but drupal core ends up in main directory instead of ./web. I know I can put installer-paths into the last composer file and overwrite it, but that's not the point. I want first file to define where stuff should be place at.
The extra settings only work for the root package. Consider user/site requiring 2 different packages that both specifiy different installer paths. Which one should composer use and how should it know? By ignoring those settings, unless they are specified in your root composer.json, composer circumvents any surprises/problems.
There is a way around this, you can create a post-install script that determines the correct path for you, e.g. by checking if myusername/composer_test is installed and the variable is set. This is a bit similar to how Symfony's Install-Script in the SensioDistributionBundle used to do it. It provides a fallback to determine the right directory to use based on configs and folder structure (due to changes in how the default directory structure looks at ~2.8, e.g. moving app/console to bin/console).
You could write your own install script that inspects the installed composer packages. The downside is, that just like you now have to specify the extra config in your second composer.json, you will have to specify the install scripts, plus you have to write the install script itself. So it might be a lot of extra work without gaining a lot from it.

Load two custom libraries

I have some problem by using Composer to load a custom library from another custom library
I have 2 custom libraries called "ia/audit_trail" and "ia/flash". And "ia/audit_trail" needs "ia/flash" to work.
audit_trail : https://github.com/pierrererot/audit_trail
flash : https://github.com/pierrererot/flash
So, I have the require property set for calling another one. Nothing special, BUT, when I run a simple composer update -vvv in my main project, I got this error :
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for ia/audit_trail_component ~1.0.0 -> satisfiable by ia/audit_trail_component[1.0.0].
- ia/audit_trail_component 1.0.0 requires ia/flash_component ~1.0.0 -> 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://getcomposer.org/doc/04-schema.md#minimum-stability for more details.
- It's a private package and you forgot to add a custom repository to find it
Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems...
BUT, if I put these two librairies directly into my main project (so if one librairy doesn't need another librairy), it works !.
Here is the composer.json of my main project :
{
"require": {
"ia/audit_trail_component": "1.0.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pierrererot/audit_trail.git"
}
]
}
All right. So I did require my custom "audit_trail" library. So now, here is the composer.json of my custom "audit_trail" library :
{
"name": "ia/audit_trail_component",
"version": "1.0.0",
"type": "library",
"require": {
"ia/flash_component": "1.0.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pierrererot/flash.git"
}
],
"minimum-stability": "dev"
}
All right. So I did require my custom "flash" library. And then, here is the composer.json of my custom "flash" library :
{
"name": "ia/flash_component",
"version": "1.0.0",
"description": "Flash Component",
"type": "library",
"minimum-stability": "dev"
}
As you can see, everything seems ok in my composer files, so I don't understand what I missed.
==> Does anyone have a clue please ?
Before you ask, I precise these things :
Both libraries have a "dev" and a "master" branch pushed on their Git repositories
Both libraries have a minimum 1.0.0 tag pushed on their Git repositories
repositories setting is root-only - Composer will ignore this setting for all dependencies and use only these repositories defined in your main project.
Repositories are only available to the root package and the repositories defined in your dependencies will not be loaded. Read the FAQ entry if you want to learn why.
https://getcomposer.org/doc/05-repositories.md#repository
So you need add all necessary repositories into composer.json of your main project:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pierrererot/audit_trail.git"
},
{
"type": "vcs",
"url": "https://github.com/pierrererot/flash.git"
}
],

trying to include a specific branch of a package not on packagist

I'm trying to use a specific branch of repo but getting an error:
composer.json
{
"name": "programmingarehard/arbiter",
"license": "MIT",
"type": "library",
"description": "Convenience library to manipulate Symfony ACL's",
"authors": [
{
"name": "David Adams",
"email": "adams.david.10#gmail.com"
}
],
"autoload": {
"psr-4": {
"ProgrammingAreHard\\Arbiter\\": "src",
"ProgrammingAreHard\\Arbiter\\Spec\\": "spec"
}
},
"require": {
"php": ">=5.3.3",
"symfony/security": "2.4.*"
},
"require-dev": {
"bestform/phpspec": "dev-psr4-support"
},
"config": {
"bin-dir": "vendor/bin"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/bestform/phpspec"
}
],
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}
Error:
Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package bestform/phpspec 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 <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
This is the repo/branch i'm trying to pull into my package. Not sure what i'm doing wrong.
The repository you are using does not contain a software named bestform/phpspec. Look at the composer.json that is in there, and use the value given as "name". Its phpspec/phpspec, and any branch will only ever be found if you use that name.
The name of the Github repository is irrelevant. Don't confuse it with the "composer" name.

Categories