dsvtnz6350 2014-05-11 16: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-12 01: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条)

报告相同问题?

悬赏问题

  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP