How can I test/install an untagged version of a composer package?

拜拜、爱过 提交于 2019-12-24 07:59:57

问题


I would like to test my private composer package on localhost without the need to commit a new tag to perform the test.

My package tree

   ├── composer.json
├── README.md
└── src
    ├── Controllers
    │ 
    ├── Models

    ├── Providers
    │   └── RouteGenericServiceProvider.php
    ├── Repositories

    ├── Routes
    │   └── generics.php
    ├── Services
    │ 
    └── Transformers

回答1:


As an alternative to what is suggested bey @Matteo, you can use an inline alias and reference a commit hash instead of a tag.

Assume that x.y.z is the version you have currently installed, and #123abc is the hash of the commit you would tag once successfully tested (probably HEAD of whatever the branch is you want to test), then run:

$ composer require "my/package:dev-master#123abc as x.y.z"

For reference, see:

  • https://getcomposer.org/doc/articles/aliases.md#require-inline-alias



回答2:


You can use the Path repository type. From the doc:

For instance, if you have the following directory structure in your repository:

- apps
\_ my-app
  \_ composer.json
- packages
\_ my-package
  \_ composer.json

Then, to add the package my/package as a dependency, in your apps/my-app/composer.json file, you can use the following configuration:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package"
        }
    ],
    "require": {
        "my/package": "*"
    }
}

Hope this help



来源:https://stackoverflow.com/questions/45680420/how-can-i-test-install-an-untagged-version-of-a-composer-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!