dsvtnz6350 2014-05-11 08:16
浏览 165
已采纳

Composer更新不会在Laravel中安装PHPUnit?

I am trying to install PHPUnit into the Laravel framework via Composer.

The problem is that the required files are not downloaded after running composer update.

My process looks like this:

First, I insert PHPUnit requirement in composer.json. The whole file looks like this:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "laravel/framework": "4.1.*",
        "laravelbook/ardent": "dev-master",
        "phpunit/phpunit": "4.2.*" // i have also tried with 3.7 and 3.8
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php",
            "app/filters"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable",
        "require": {
            "laravelbook/ardent": "dev-master"
        }

}

Next, I run composer update -vvv. The dump looks like this (Bonus Weirdness: This is copied from command prompt, wierdly enough if i do the same command but try to write it to a txt file with the > command, the process hangs after the Downloading https://packagist.org/packages.json line)

C:\wamp\www\Dropbox\ltest>composer update -vvv
Reading ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Loading composer repositories with package information
Downloading https://packagist.org/packages.json
Writing C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/packages
.json into cache
Updating dependencies (including require-dev)
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/p-provid
er-active.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/p-provid
er-archived.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/p-provid
er-latest.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/p-provid
er-stale.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-laravelbook$ardent.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-laravel$laravel.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-psr$log.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$http-foundation.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$http-kernel.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-stack$builder.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$event-dispatcher.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$debug.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-predis$predis.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-phpseclib$phpseclib.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-nesbot$carbon.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-monolog$monolog.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-nikic$php-parser.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-jeremeamia$superclosure.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-jeremeamia$functionparser.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-ircmaxell$password-compat.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-filp$whoops.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-d11wtq$boris.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$console.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$filesystem.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$finder.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-classpreloader$classpreloader.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-patchwork$utf8.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-swiftmailer$swiftmailer.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$browser-kit.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$css-selector.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$dom-crawler.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$process.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$routing.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$security.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$translation.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-laravel$framework.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-doctrine$dbal.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-doctrine$common.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-doctrine$inflector.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-doctrine$cache.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-doctrine$collections.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-doctrine$lexer.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-doctrine$annotations.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$support.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$database.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$validation.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$container.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$events.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$auth.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$cache.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$config.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$console.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$cookie.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$encryption.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$exception.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$filesystem.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$foundation.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$hashing.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$html.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$http.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$log.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$mail.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$pagination.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$queue.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$redis.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$routing.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$session.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$translation.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$view.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-illuminate$workbench.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$security-acl.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$security-core.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$security-csrf.json from cache
Reading C:/Users/aske/AppData/Local/Composer/repo/https---packagist.org/provider
-symfony$security-http.json from cache
Nothing to install or update
Reading ./composer.lock
Generating autoload files
Executing command (CWD): php artisan clear-compiled
Executing command (CWD): php artisan optimize
Generating optimized class loader

And in the end required files are not added to vendor/bin/. As far as I know a file called phpunit.php should have been placed there at this point, but there is no sign of it.

Here is my composer.lock as bonus info, no sign of any phpunit after running update.

展开全部

  • 写回答

2条回答 默认 最新

  • dougu3290 2014-05-11 17:37
    关注

    The reason the addition of PHPUnit fails is because you have TWO keys named "require" in your composer.json, which is illegal. The last instance overwrites the first instance - which overwrites the added PHPUnit requirement.

    Only after changing this to "require-dev", which is a different key, Composer can detect that you want PHPUnit.

    {
        "name": "laravel/laravel",
        "description": "The Laravel Framework.",
        "keywords": ["framework", "laravel"],
        "license": "MIT",
        "require": {
            "laravel/framework": "4.1.*",
            "laravelbook/ardent": "dev-master",
            "phpunit/phpunit": "4.2.*" // i have also tried with 3.7 and 3.8
        },
    
        // deleted lines here...
    
        "minimum-stability": "stable",
            "require": {
                "laravelbook/ardent": "dev-master"
            }
    
    }
    

    See that mention of "require" as the last, badly indented key inside the JSON? This will confuse Composer at the least. I'm pretty sure "laravelbook/ardent" has a dependency on "laravel/framework" and plenty of additional stuff, so you didn't see that your first require key was overwritten.

    Suggestion: Always use the command line to add stuff - it is way easier, and you don't have to take care of correct JSON formatting:

    composer require --dev phpunit/phpunit:~4.0
    

    This will add the dependency to the composer.json file and then download it right away if there are no conflicts. It will also write a new, cleanly formatted composer.json file. You'd have spotted your error quickly if Composer had the chance to remove the double key.

    展开全部

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥66 android运行时native和graphics内存详细信息获取
  • ¥100 求一个c#通过CH341读取数据的Demo,能够读取指定地址值的功能
  • ¥15 rk3566 Android11 USB摄像头 微信
  • ¥15 torch框架下的强化学习DQN训练奖励值浮动过低,希望指导如何调整
  • ¥35 西门子博图v16安装密钥提示CryptAcquireContext MS_DEF_PROV Error of containger opening
  • ¥15 mes系统扫码追溯功能
  • ¥40 selenium访问信用中国
  • ¥20 在搭建fabric网络过程中遇到“无法使用新的生命周期”的报错
  • ¥15 Python中关于代码运行报错的问题
  • ¥500 python 的API,有酬谢
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部