Laravel在自己的项目中使用包裹



我正在 Laravel 5.5中构建一个软件包。现在我想使用该软件包在我自己的项目中本地。

我包装中的composer.json看起来像:

{
    "name": "larsjanssen6/underconstruction",
    "license": "MIT",
    "homepage": "https://github.com/larsjanssen6/underconstruction",
    "authors": [
        {
            "name": "Lars Janssen",
            "email": "larsjanssen64@gmail.com",
            "role": "Developer"
        }
    ],
    "require": {
        "php" : "^7.0",
        "illuminate/support": "~5.5.0"
    },
    "autoload": {
        "psr-4": {
            "LarsJanssen\underconstruction\": "src/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "laravel": {
            "providers": [
                "LarsJanssen\underconstruction\UnderConstructionServiceProvider"
            ]
        }
    }
}

(https://github.com/larsjanssen6/underconstruction)

在一个新的Laravel项目中,我在Composer.json文件中添加了这样的包装:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/larsjanssen6/underconstruction"
        }
    ],
    "require": {
        "php": ">=7.0.0",
        "fideloper/proxy": "~3.3",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
        "larsjanssen6/underconstruction": "master"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~6.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

但是我收到此错误:

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - The requested package larsjanssen6/underconstruction could not be found in any version, there may be a typo in the package name.

这里可能是什么问题?

从评论部分移动答案。

您需要需要dev-master才能获取Master的分支代码。

如果您有某种其他分支,请说second-branch,您将在 composer.json 文件中使用dev-second-branch

...
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/larsjanssen6/underconstruction"
    }
],
"require": {
    ...
    "larsjanssen6/underconstruction": "dev-master"
},
...

相关内容

  • 没有找到相关文章

最新更新