作曲家 - 同时处理项目和依赖

I have a project that contains a subproject. They are in separate repositories.

In a production environment the subproject would be a dependency of the main project declared in the composer.json file.

In my development environment I would like to able to work with both projects at the same time. I don't want to composer update my subproject everytime I modify it.

At the moment I have my subproject included in a subfolder of the main project which is .gitignored, in such a way that it is not seen from the main repository but it is seen by the application. This approach poses a series of problems, like:

  • I need to have differente compose.json in development and in production
  • In developmente I need to load the dependencies if the subproject through the composer.json of the main project

Is there a way to make composer handle this situation all by itself? Is there some better solution to do this?

I don't think there is a perfect solution. The best you can do is to change the version number of your sub-project to the branch you are working on (such as dev-master) and run composer update. You can then work directly in the sub-project code in your vendor directory. You can even commit and push your code from there. The downside is that you have to be careful when you commit your composer.json and composer.lock files because of the manual dev-only changes. Changes to those files don't happen terribly often, so it's not too bad.