简体   繁体   中英

Running 2 composer.json files

I have PHP (Laravel) project that I'm developing, and it uses a helper package that I've developed and that gets modified as well while I work on the original project. I want to know the best way to deal with this in composer.

Right now, in my composer.json file, I have a repository path so that the project knows to always use my current version.

"repositories": {
    "local": {
      "type": "path",
      "url": "../../packages/my-account/my-package"
    }
  }

The path is in the require path of the main project as it contains files that are extended in the project.


 "require": {
    "php": "^7.1.3",
    "fideloper/proxy": "^4.0",
    "laravel/framework": "5.8.*",
    "laravel/tinker": "^1.0",
    "nothingworks/blade-svg": "^0.3.0",
    "my-account/my-package": "^0.3.8@dev",

...

I used to just have both projects open, and then update the package, and push it to packagist. Then wait while the other package downloads the update but it seemed to be such a time waster, especially since to run some unit tests I'd only find the issue after upgrading.

Instead, I have a soft link in my system (MacOS Mojave) from my vendor folder to my account folder to make sure that in PhpStorm, I can open the files I need to and make changes to the projects both at the same time. I basically only ever have to commit, when everything is working as expected. This has been a massive time save, however it has a drawback...

Every time I commit to the primary project I need to remove the repositories chunk from my composer.json to push it to staging or to production. Since there is no repositories-dev or something of that nature.

Is there a better workflow? Using 2 composer.jsons? OR some PhpStorm magic that can solve this so I'm not stripping out the hunk of code on each commit?

You can use https://github.com/franzliedke/studio which solves your exact problem. It saves you from modifying the composer.json file to add a symlink to your package, as it does the exact same thing on the fly, via a Composer plugin.

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