x-yuri x-yuri - 7 days ago 5
PHP Question

How to fork with reverse dependencies?

I forked

laravel/framework
and want to use clone's
testing-encoding
branch:

{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/x-yuri/framework"
}
],
"require": {
"laravel/framework": "dev-testing-encoding"
}
}


But when I do
composer require modelizer/selenium
, it says:

Using version ^1.1 for modelizer/selenium
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- laravel/framework 5.4.x-dev requires symfony/console 3.2.* -> satisfiable by symfony/console[3.2.x-dev, v3.2.0-BETA1, v3.2.0-RC1, v3.2.0-RC2] but these conflict with your requirements or minimum-stability.
- laravel/framework 5.4.x-dev requires symfony/console 3.2.* -> satisfiable by symfony/console[3.2.x-dev, v3.2.0-BE
TA1, v3.2.0-RC1, v3.2.0-RC2] but these conflict with your requirements or minimum-stability.
- Installation request for modelizer/selenium ^1.1 -> satisfiable by modelizer/selenium[v1.1.0].
- Conclusion: remove laravel/framework dev-testing-encoding
- Conclusion: don't install laravel/framework dev-testing-encoding
- modelizer/selenium v1.1.0 requires laravel/framework ^5.1 -> satisfiable by laravel/framework[5.4.x-dev, 5.1.x-de
v, 5.2.x-dev, 5.3.x-dev].
- Can only install one of: laravel/framework[5.1.x-dev, dev-testing-encoding].
- Can only install one of: laravel/framework[5.2.x-dev, dev-testing-encoding].
- Can only install one of: laravel/framework[5.3.x-dev, dev-testing-encoding].
- Can only install one of: laravel/framework[dev-testing-encoding, 5.1.x-dev].
- Can only install one of: laravel/framework[dev-testing-encoding, 5.2.x-dev].
- Can only install one of: laravel/framework[dev-testing-encoding, 5.3.x-dev].
- Installation request for laravel/framework dev-testing-encoding -> satisfiable by laravel/framework[dev-testing-e
ncoding].


Installation failed, reverting ./composer.json to its original content.


I tried to experiment with
minimum-stability
, and stability flags. To no avail. The best I could come up with is fork
modelizer/selenium
as well, and hardcode there
laravel
's branch I need:

diff --git a/composer.json b/composer.json
index 9036e47..65facf0 100644
--- a/composer.json
+++ b/composer.json
@@ -12,8 +12,14 @@
"email": "john.hoopes@madisoncreativeweb.com"
}
],
+ "repositories": [
+ {
+ "type": "vcs",
+ "url": "https://github.com/x-yuri/framework"
+ }
+ ],
"require": {
- "laravel/framework": "^5.1",
+ "laravel/framework": "dev-testing-encoding",
"symfony/process": ">=2.7",
"phpunit/phpunit-selenium": ">=1.2",
"guzzlehttp/guzzle": "^6.2"


Add the repo to root
composer.json
:

{
"type": "vcs",
"url": "https://github.com/x-yuri/Selenium"
}


And then do:
composer require modelizer/selenium=dev-laravel-testing-encoding
. Which also means, I've got to fork
laravel/socialite
too, though it doesn't require
laravel/framework
directly. Can it be any simpler than this?

Answer

The guys on GitHub helped me with this one. As you can see, modelizer/selenium requires laravel/framework=^5.1. And we want laravel/framework=dev-testing-encoding. composer doesn't know how to compare these two versions, unless we tell it:

"require": {
    "laravel/framework": "dev-testing-encoding as 5.1.0"
}

This way, we convey to composer that dev-testing-encoding can be treated as version 5.1.0. In other words, we alias dev-testing-encoding to 5.1.0. As such, it satisfies modelizer/selenium's dependency, and requiring the package succeeds.