Composer Use Github Before Packagist - php

I have made a fork of FOSRestBundle here RLovelett/FOSRestBundle it has a branch dev-411. I want to use my fork and branch of FOSRestBundle in a Symfony2 project.
To attempt this I patched my symfony2 project composer.json like so (full composer.json):
diff --git a/composer.json b/composer.json
index ec36007..19e82b5 100644
--- a/composer.json
+++ b/composer.json
## -23,7 +23,7 ##
"jms/security-extra-bundle": "1.4.*",
"jms/di-extra-bundle": "1.3.*",
"jms/serializer-bundle": "0.12.x-dev",
- "friendsofsymfony/rest-bundle": "0.11.*"
+ "friendsofsymfony/rest-bundle": "dev-411"
},
"scripts": {
"post-install-cmd": [
## -42,12 +42,18 ##
"config": {
"bin-dir": "bin"
},
- "minimum-stability": "alpha",
+ "minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"branch-alias": {
"dev-master": "2.2-dev"
}
- }
+ },
+ "repositories": [
+ {
+ "type": "vcs",
+ "url": "https://github.com/RLovelett/FOSRestBundle"
+ }
+ ]
}
When I run composer update I get the following error message:
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package friendsofsymfony/rest-bundle dev-411 could not be 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 <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
What is wrong with my configuration?

Composer prefixes dev- to branch names to identify them clearly, so if the branch is dev-411, the composer version for it would be dev-dev-411.

Try this : "friendsofsymfony/rest-bundle": "0.11.dev-feature/411"
More infos here : https://github.com/composer/composer/issues/935

Related

Referenced sniff "PHPCSUtils" does not exist

I have PhpStorm and installed "squizlabs/php_codesniffer". When I try to use (e.g. modify the source code), PhpStorm sends me a little error every time, as
Referenced sniff "PHPCSUtils" does not exist
I tried to get that PHPCSUtils like that:
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require phpcsstandards/phpcsutils:"^1.0"
from here: https://phpcsutils.com/
but it then says:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires phpcsstandards/phpcsutils ^1.0, found phpcsstandards/phpcsutils[dev-stable, dev-develop, 1.0.0-alpha1,
..., 1.x-dev (alias of dev-stable)] but it does not match your
minimum-stability.
When I try composer require phpcsstandards/phpcsutils:"dev-stable" I get
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires phpcsstandards/phpcsutils dev-stable -> satisfiable by phpcsstandards/phpcsutils[dev-stable].
- phpcsstandards/phpcsutils dev-stable requires squizlabs/php_codesniffer ^3.7.1 || 4.0.x-dev#dev -> satisfiable by
squizlabs/php_codesniffer[3.7.1] from composer repo
(https://repo.packagist.org) but squizlabs/php_codesniffer is the root
package and cannot be modified. See
https://getcomposer.org/dep-on-root for details and assistance.
but that's a lie, I got 3.7.1 phpcodesniffer version:
phpcs --version
PHP_CodeSniffer version 3.7.1 (stable) by Squiz (http://www.squiz.net)
my composer.json is:
{
"require": {
"squizlabs/php_codesniffer": "^3.7"
}
}
the phpcs composer.json is:
{
"name": "squizlabs/php_codesniffer",
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
"type": "library",
"keywords": [
"phpcs",
"standards"
],
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Greg Sherwood",
"role": "lead"
}
],
"support": {
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki",
"source": "https://github.com/squizlabs/PHP_CodeSniffer"
},
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"require": {
"php": ">=5.4.0",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"ext-simplexml": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"bin": [
"bin/phpcs",
"bin/phpcbf"
],
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

Composer pull dependency from another branch on the same repo

I have the following Composer 1.6.5 setup:
"require": {
"CRMPicco/GolfBundle": "dev-golf-bundle"
},
"repositories": [
{
"type": "git",
"url": "git#git.crmpicco.com:frontend/app.git"
}
],
On the origin of git.crmpicco.com:frontend/app.git there exists the main branch of master and also a golf-bundle branch. I want to have the contents of the golf-bundle branch as a composer dependency in the /vendor directory. When I run a composer update CRMPicco/GolfBundle I get the following error:
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- The requested package crmpicco/golfbundle dev-golf-bundle exists as CRMPicco/GolfBundle[dev-master] but these are rejected by your
constraint.
I have also flushed the cache and run dump-autoload:
composer clear-cache
composer dump-autoload --optimize
How can I configure composer to pull from the "golf-bundle" branch?
My composer.json from the golf-bundle branch:
{
"name": "CRMPicco/GolfBundle",
"type": "library",
"require": {
"php": ">=7.0",
"symfony/config": "~2.8.34",
"symfony/dependency-injection": "~2.8.34",
"symfony/http-kernel": "~2.8.34",
"chargebee/chargebee-php": "^2.0"
},
"autoload": {
"psr-4": {
"CRMPicco\\GolfBundle\\": ""
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative"
}
}

but these conflict with your requirements or minimum-stability

I am creating my own slackbot. I decided to use project as a library to help me.
https://github.com/sagebind/slack-client/issues?utf8=%E2%9C%93&q=stability
Now I need to install it with composer.
So I used the command: composer require coderstephen/slack-client
...And I get the error:
Problem 1
- Installation request for coderstephen/slack-client ^0.3.0 -> satisfiable by coderstephen/slack-client[v0.3.0].
- coderstephen/slack-client v0.3.0 requires devristo/phpws dev-master -> satisfiable by devristo/phpws[dev-master] but these conflict with your requirements or minimum-stability.
Ok - So then I decided to change my stability level to "dev" in my composer.lock:
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {
"devristo/phpws": 20
},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">=5.5"
},
"platform-dev": []
Now I'm running out of ideas on what to do. The README says to do this step in composer.json but, no such settings exist:
Please note that the current version has unstable dependencies.
In order to install those dependencies, you can set "minimum-stability" in your composer.json, and recommend that you set "prefer-stable":
My composer.json:
{
"name": "coderstephen/slack-client",
"keywords": ["slack", "api", "realtime"],
"license": "MIT",
"description": "A better Slack client, with RTM API support",
"authors": [{
"name": "Stephen Coakley",
"email": "me#stephencoakley.com"
}],
"require": {
"php": ">=5.5",
"devristo/phpws": "dev-master",
"evenement/evenement": "2.0.*",
"guzzlehttp/guzzle": "~6.0",
"react/event-loop": "^0.4.1",
"react/promise": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"fzaninotto/faker": "~1.4",
"apigen/apigen": "^4.1"
},
"autoload": {
"psr-4": {
"Slack\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Slack\\Tests\\": "tests"
}
}
}
Does anyone know some solutions I could try?
Add minimum-stability and prefer-stable to your composer.json (not composer.lock):
{
"name": "coderstephen/slack-client",
"keywords": ["slack", "api", "realtime"],
"license": "MIT",
"description": "A better Slack client, with RTM API support",
"authors": [{
"name": "Stephen Coakley",
"email": "me#stephencoakley.com"
}],
"require": {
"php": ">=5.5",
"devristo/phpws": "dev-master",
"evenement/evenement": "2.0.*",
"guzzlehttp/guzzle": "~6.0",
"react/event-loop": "^0.4.1",
"react/promise": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"fzaninotto/faker": "~1.4",
"apigen/apigen": "^4.1"
},
"autoload": {
"psr-4": {
"Slack\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Slack\\Tests\\": "tests"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
For others having the same issue, these changes are best done using composer itself instead of manually modifying the composer.json file. Just run the following commands in the console:
$ composer config minimum-stability dev
$ composer config prefer-stable true
Now you can require and update the package:
$ composer require --no-update "vendor/package-name:version"
$ composer update
Available options (in order of stability) are dev, alpha, beta, RC, and stable
You should never manually edit the composer.lock file - it is an automatically generated file.
It looks like you've shown the composer.json file of the package you're trying to require rather than your own project's composer.json. The prefer-stable and minimum-stability properties should be added to your project root's composer.json file:
{
"name": "xFlare/slack-bot",
"description": "xFlare's Slack bot project",
"authors": [
{
"name": "xFlare"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.5",
"coderstephen/slack-client": "^0.3.0"
}
}
Usually, this issue has nothing to do directly with minimum-stability or prefer-stable option, but the case is just that you already use some library directly or indirectly, that is needed in another library you use but in a higher version.
My case: Got this error message for a Codeception library which needed a dependency of PHPUnit at least of version 6 and above (>= 6) , but it clashed with the lower version 4 of PHPUnit dependency, which I had installed/required directly already before prior it (as a package in my composer.json file). (my specific case could not use higher PHPUnit than version 6, since it was the last version which supported php version I used).
You might ask if it might affect your project, which already relies on the lower version of the library, perhaps there could be some breaking change, but I don't know if there could be some workaround for using one version for dependency and another version for own project.
Edit: I also had to issue a remove composer command for phpunit dependency, otherwise I was not able to increase my phpunit version directly.
You should add the minimum-stability in your composer.json not in the composer.lock. The option exists see https://getcomposer.org/doc/04-schema.md#minimum-stability
i had the error in a symfony4 project with own bundles.
my-foo-bundle dev-master requires ramsey/uuid-doctrine ^1.5 -> satisfiable by ramsey/uuid-doctrine[1.5.0, 1.6.0] but these conflict with your requirements or minimum-stability.
the solution, i search for "ramsey/uuid-doctrine" in my bundles and i found different requirements "ramsey/uuid-doctrine ^1.5" (in my-foo-bundle) and "ramsey/uuid-doctrine dev-master" (in my app-configuration). So i delete the requirement in the app/composer.json.
This worked for me.

How to use the develop branch of Zend Framework 2 over composer?

In an Apigility driven application my composer.json is looking like this:
{
"name": "misc - myproject-api",
"description": "Skeleton Application for Apigility",
"require": {
"php": ">=5.3.23",
"zendframework/zendframework": ">=2.3.2,<3.0.0",
"zfcampus/zf-apigility": "~1.0",
"zfcampus/zf-apigility-documentation": "~1.0",
"zfcampus/zf-development-mode": "~2.0",
"zfcampus/zf-rest": "~1.0-dev",
"zf-commons/zfc-base": "dev-master",
"zendframework/zend-developer-tools": "dev-master",
"doctrine/doctrine-orm-module": "0.8.*"
},
"require-dev": {
"zendframework/zftool": "dev-master",
"zfcampus/zf-apigility-admin": "~1.0",
"zfcampus/zf-apigility-welcome": "~1.0",
"zfcampus/zf-deploy": "~1.0",
"zfr/zfr-cors": "~1.0",
"zend/zend-studio-development-mode": "~1.0"
},
"keywords": [
"api",
"apigility",
"framework",
"zf2"
],
"support": {
"email": "apigility-users#zend.com",
"irc": "irc://irc.freenode.net/apigility",
"source": "https://github.com/zfcampus/zf-apigility-skeleton",
"issues": "https://github.com/zfcampus/zf-apigility-skeleton/issues"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
"dev-develop": "1.1-dev"
}
},
"config": {
"process-timeout": 5000
},
"type": "library",
"license": "BSD-3-Clause",
"homepage": "http://apigility.org/"
}
There is a ZF2 issue (that causes following error: Fatal error: Cannot use object of type Zend\Db\ResultSet\ResultSet as array). It has been fixed, but not merged to the master branch yet.
Since I need it working now, I tried to switch to the develop branch -- updated my composer.json
{
"name": "misc - myproject-api",
"description": "Skeleton Application for Apigility",
"require": {
"php": ">=5.3.23",
"zendframework/zendframework": "dev-develop as dev-master"
...
}
...
}
and executed a composer update:
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Updating zendframework/zendframework (dev-master de98f63 => dev-develop be0b349)
Checking out be0b3496b73a61a255d05e945b75f6fdf0995c31
Writing lock file
Generating autoload files
Problem: I'm not observing any changes, the code seems still to be loaded from the ZF2 master branch (e.g. my local Zend\Paginator\Adapter\DbSelect has exactly the state of the according class in the master branch).
How to load the ZF2 develop branch?
UPDATE
I've triedthe the composer require direction value for the develop branch (2.4.*#dev) from the Packagist page of the Zend Framework. The result is the same as with dev-develop or dev-develop as dev-master -- the console shows the correct branch (or better the correct commit be0b349) downloading
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing zendframework/zendframework (2.3.4)
- Installing zendframework/zendframework (dev-develop be0b349)
Cloning be0b3496b73a61a255d05e945b75f6fdf0995c31
Writing lock file
Generating autoload files
but after the updating, the code is still like in the master branch.
UPDATE
$ cd [project root directory]/vendor/zendframework/zendframework
$ git status
# On branch develop
nothing to commit (working directory clean)
That means, the branch is correct. And its also up-to-date, since the last commit , git log shows is be0b3496b73a61a255d05e945b75f6fdf0995c31 from 3d of February -- and that is actually the current HEAD revision.
So, the branch is correct, the revision is correct... Why is the code uot-of-date?
The "develop" branch has an alias to be version 2.4. You could require "2.4.*#dev" to get it.
If this breaks some of your dependencies, you could alias this with a 2.3 version.
"zendframework/zendframework": "dev-develop as 2.3.4.1"

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