Composer not installing local package dependencies

心不动则不痛 提交于 2019-12-08 10:40:02

问题


In my Laravel 5.4 composer.json file I have the following that autoloads my custom package. Note, that this package is not published and is being loaded locally.

"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/",
        "Vendor\\Module\\": "packages/vendor/module/src"
    }
},

And then in my package composer.json file I have the following

{
    "name": "vendor/module",
    "description": "A custom package",
    "version": "1.0.0",
    "type": "project",
    "authors": [
    ],
    "minimum-stability": "dev",
    "require": {
      "laravelcollective/html": "^5.4.0"
    }
}

However, when I run composer install from the root Laravel directory, it never picks up the laravelcollective/html package that I am requiring.

Is there a way to load in dependencies on a local package that is not published?


回答1:


I believe I found a solution, all though it may not be the best method for local package development it is working for me.

In the root composer.json file, I added the following and running a composer update from the root of the application seems to now pick up the package and it's dependencies and installs everything into the main vendor directory of the root application.

"repositories": [
    {
        "type": "path",
        "url": "packages/vendor/module"
    }
],
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.7",
    "vendor/module": "1.0.*"
},
"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/",
        "Vendor\\Module\\": "packages/vendor/module/src"
    }
},

The good thing about this method is it creates a symbolic link only for the custom package, thus you can continue to write updates in the packages directory and the changes will take affect instead of having to commit to your local git repository if you set the type to vcs in the repositories field of the composer.json.

I also had to specify in the require-dev field the version number so that it passes the version constraint, otherwise you would get a warning that the package does not meet the minimum version requirements when running composer.



来源:https://stackoverflow.com/questions/45870095/composer-not-installing-local-package-dependencies

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