简体   繁体   中英

Working on dependent, unpublished libraries with Composer

Let me first describe what I'm doing:

I'm working on two libraries, call them A and B - neither of these are public anywhere, and I don't want to publish them until they're stable.

Library A depends on Library B.

These two libraries are in separate, local Git repositories, and have individual composer.json files.

My problem is this: during development, I need a way to specify the dependency on Library B in Library A - which is simple enough, it's just an entry in the "require" section of Library A, and since nothing is versioned or committed yet, I'm specifying "dev-master" as the version requirement.

The issue is, library B of course does not really "exist" anywhere yet, as this is all local development on local Git repositories.

What I don't want, is I don't want to have to commit changes to Library B and having to do a composer install for Library A for every incremental change.

In fact, I don't want to "install" library B at all, as long as I'm just working on the repositories locally - that is, I don't want copies of Library B in Library A's vendor folder, I just want the generated auto-loader for Library A to point directly to my local Library B folder.

Surely there must be a way to do this? I have spent half a day searching and reading the documentation, blog posts, third-party guides, stack overflow questions, etc. - and found nothing.

Isn't this a totally common scenario and requirement for pretty much any developer?

Ideally, I also would like to be able to do this with a local file somehow - that is, I would rather not have to pollute my composer.json file with settings that are only relevant to me while I'm developing. But this is secondary - I can live with having to "hack" my local composer.json and avoid checking in the changes during development, but I cannot live with having to commit and install/update/copy files with every incremental change.

Any ideas?

It's not that common I think that people work on two brand new libs at once, but I agree we should support this better somehow.

I think the easiest/only way to do this is to install libB in libA using a local VCS repository definition (file:///path/to/foo/.git works), and then replace vendor/lib/A by a symlink to libA's folder. Just be careful if you run update because I'm not quite sure what happens in that case.

The other less pretty but perhaps easier way is to just develop libB in the vendor dir of libA, you can run install in libB's folder to get any dev dependencies. It's a bit ugly but not so dramatic IMO.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM