douzachan4578 2017-09-22 14:01
浏览 371
已采纳

具有dev依赖项的Composer安装包

How do I install a composer package with dev dependencies?

So for example:

When I have this package:

https://github.com/spatie/laravel-demo-mode

And I run:

composer require spatie/laravel-demo-mode

The tests folder is not installed?!

  • 写回答

1条回答 默认 最新

  • dongtan2603 2017-09-22 16:36
    关注

    In short you don't (ever). If you want to contribute, you need to set up new Laravel project and set up composer to autoload your version of package, either from your fork or from somewhere on your disk. And when you do that you are just using your version of the package (again without the possibility to run packages's tests).

    In order to run tests of the package you need to change directory to the root of the package and install its dependencies ($ composer install), after you've done that you may run $ phpunit.


    What I am usually doing in when I want to contribute is:

    • have empty Laravel project ready (unversioned)
    • have packages folder in root
    • in that packages folder I usually do $ git clone <repo fork> (It may be more than one package at once)
    • in case I want to run package's tests I do $ composer install and $ phpunit (your IDE may squeak at you about duplicate definitions but you may ignore it)
    • improve and test the code of package in packages folder
    • test your changes "live" on Laravel project right-away

    composer.json may look like:

    ...
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/",
            "Vendor\\Package\\": "packages/path-to-src/"
        }
    },
    ...
    

    You may find useful this example repo I use https://github.com/Kyslik/column-sortable-example to demonstrate how to work with package I maintain. Mainly take a look at folder structure and composer.json.

    There may be better ways on how to do contributing but I have only found (and developed) this one.


    If I have small changes in mind (like typo, or just return type or whatever is "small") I do change package within vendor folder, and see if it breaks anything; after that I fork package source and edit the change right in the Github's web interface. To clean up just run $ composer install/update from root folder of your Laravel project.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作