Working on forked GitHub repository through Composer

后端 未结 1 1952
甜味超标
甜味超标 2021-01-21 07:58

I hope my question is not too vague, but can\'t get a proper answer by searching.

I have the following situation; We are working on a project and have certain dependenci

1条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-21 08:56

    1. Change package constraint in composer.json to use branch instead of tagged version - you can use dev-master for master branch or dev-my-branch for my-branch branch. You may also configure branch alias.

      "require": {
          "some-vendor/some-package": "dev-master",
      }
      
    2. Add a repository which points to your fork:

      "repositories": [
          {
              "type": "git",
              "url": "https://github.com/richard/some-package/"
          },
      ]
      
    3. Run composer update to install new version from your fork (or composer require "some-vendor/some-package:dev-master" if you don't want to update any other dependencies).

    Now you should have sources cloned from your fork in vendor/some-vendor/some-package. You can edit these files and test if changes fits to your app. After you finish your work:

    1. Commit changes in your fork and push them to GitHub.
    2. Go back to root of your app and run composer update or composer require "some-vendor/some-package:dev-master". This will update your composer.lock file to use latest version of your fork. Then commit changes in your lock and push.

    Now if someone will clone your project (or just pull changes) it will get new composer.lock pointing to your fork with specified commit hash - composer install should always install the same version of your fork directly from GitHub.

    0 讨论(0)
提交回复
热议问题