通过Github fork加载composer包

时间:2017-07-28 15:25:15

标签: composer-php

我在Github上分叉了一个库,现在想要将fork加载到项目中而不将forked库添加到packagist中。添加存储库后,我得到以下错误,并且需要我的composer.json:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package cnizzardini/ssl-certificate could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

这是我的完整composer.json

{
    "name": "cakephp/app",
    "description": "CakePHP skeleton app",
    "homepage": "http://cakephp.org",
    "type": "project",
    "license": "MIT",
    "require": {
        "php": ">=5.5.9",
        "cakephp/cakephp": "~3.4",
        "mobiledetect/mobiledetectlib": "2.*",
        "cakephp/migrations": "~1.0",
        "cakephp/plugin-installer": "*",
        "guzzlehttp/guzzle": "^6.2",
        "donatj/phpuseragentparser": "^0.7.0",
        "cnizzardini/ssl-certificate": "dev-master"
    },
    "require-dev": {
        "psy/psysh": "@stable",
        "cakephp/debug_kit": "~3.2",
        "cakephp/bake": "~1.1",
        "phpunit/phpunit": "^5.5"
    },
    "suggest": {
        "phpunit/phpunit": "Allows automated tests to be run without system-wide install.",
        "cakephp/cakephp-codesniffer": "Allows to check the code against the coding standards used in CakePHP."
    },
    "autoload": {
        "psr-4": {
            "App\\": "src",
            "Api\\": "./plugins/Api/src",
            "Channel\\": "./plugins/Channel/src",
            "System\\": "./plugins/System/src",
            "Admin\\": "./plugins/Admin/src"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Test\\": "tests",
            "Cake\\Test\\": "./vendor/cakephp/cakephp/tests",
            "Api\\Test\\": "./plugins/Api/tests",
            "Channel\\Test\\": "./plugins/Channel/tests",
            "System\\Test\\": "./plugins/System/tests",
            "Admin\\Test\\": "./plugins/Admin/tests"
        }
    },
    "scripts": {
        "post-install-cmd": "App\\Console\\Installer::postInstall",
        "post-create-project-cmd": "App\\Console\\Installer::postInstall",
        "post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/cnizzardini/ssl-certificate.git"
        }
    ],
    "minimum-stability": "stable",
    "prefer-stable": true
}

我尝试在有和没有.git的情况下添加https://github.com/cnizzardini/ssl-certificate。我也试过设置dev的最小稳定性,而将prefer-stable设置为false。

没有任何作用: - (

1 个答案:

答案 0 :(得分:3)

您叉子上的composer.json文件仍会调用包"spatie/ssl-certificate",因此您需要的包名称。

这应该有效:

{
    ...
    "require": {
        ...
        "spatie/ssl-certificate": "dev-master"
    },
    ...
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/cnizzardini/ssl-certificate.git"
        }
    ],
    ...
}

如果没有,您可以通过更改name文件中的composer.json属性来重命名自己的分发包:

{
    "name": "cnizzardini/ssl-certificate",
    "description": "A class to easily query the properties of an ssl certificate ",
    ...
}