I've got a couple of libraries [Foo and Bar] that I'm developing in concert, but are still technically separate things. Previously I've just re-defined the autoloader to like "Foo\\": "../Foo/src"
, but now that I've added a Guzzle dependency to Foo, Bar flips it's lid because it's not one of its dependencies.
Directory structure:
/home/user/src/
Foo/
src/
FooClient.php
composer.json
Bar/
src/
BarClient.php
composer.json
Theoretical Autoload Statement: [in Bar/composer.json]
"require": {
"local": "../Foo/composer.json"
}
Example code:
require('vendor/autoload.php');
$f = new \Bar\BarClient(new \Foo\FooClient());
How can I resolve this without setting up a local Composer repo? I want to maintain these as separate packages, just that one requires the other, and therefor processes the other's dependencies.
post-answer edit:
Thanks to infomaniac I've done the following:
Initialized the git repo:
cd ~/src/Foo && git init && echo -e "vendor\ncomposer.lock" > .gitignore && git add ./ && git commit -m "Initial Commit"
Added the composer config:
"require": {
"sammitch/foo": "dev-master"
},
"repositories": [{
"type": "vcs",
"url": "/home/sammitch/src/Foo"
}],
And then composer update
!
sammitch/foo
is the package name and has literally nothing to do with where it is located. Will construct a list of available packages based on its configured repos, in this case fetching the composer.json from the specified local git repo, and then composer handles the rest. Thesammitch/foo
package is copied to the current app'svendor
folder the same as any other package. – Sammitch