Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer won't install "require-dev" packages

Tags:

composer-php

I'm trying to do some development with Laravel, and for some reason I can't get it to install any of the packages listed in the require-dev section in any of the dependencies' composer.json files. AFAIK, dev dependencies are supposed to be installed by default. I've tried it with and without the --dev flag on composer install. I've also tried removing the contents of vendors/ and deleting composer.lock and ~/.composer and reinstalling all the dependencies from scratch, but still no luck. I've also tried various iterations of the composer update command.

For example, in vendor/laravel/framework/composer.json, it lists these:

"require-dev": {
    "aws/aws-sdk-php": "2.4.*",
    "iron-io/iron_mq": "1.4.*",
    "pda/pheanstalk": "2.1.*",
    "mockery/mockery": "0.8.0",
    "phpunit/phpunit": "3.7.*"
},

None of these are getting installed. Any ideas what am I missing? Here's my main composer.json file, FWIW.

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
    "laravel/framework": "4.0.*",
    "rncryptor/rncryptor-php": "1.*"
},
"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/libraries",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ]
},
"scripts": {
    "post-install-cmd": [
        "php artisan optimize"
    ],
    "pre-update-cmd": [
        "php artisan clear-compiled"
    ],
    "post-update-cmd": [
        "php artisan optimize"
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ]
},
"config": {
    "preferred-install": "dist"
},
"minimum-stability": "dev"
}

I ran composer self-update, so it should be the latest version. Running composer --version shows this:

Composer version b20021cc6aa113069e4223b78d0074a1fc7dd4e8 2014-01-14 16:22:09
like image 428
curtisdf Avatar asked Jan 16 '14 05:01

curtisdf


People also ask

Why is composer not installing?

Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php -- --check . Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer.

What is require Dev in composer?

The package will not be installed unless those requirements can be met. require-dev (root-only) Lists packages required for developing this package (1), or running tests, etc. The dev requirements of the root package only will be installed if install is run with --dev or if update is run without --no-dev .

What is composer install no Dev?

After adding and installing dev dependencies with Flex recipes, subsequently running composer install --no-dev removes the dev packages as expected, but also reverts the changes made by the recipes in various version-controlled files and removes the package from symfony.


2 Answers

Composer only ever installs the packages listed as "require-dev" of your main composer.json file, and if these packages do need something else, then only their "require" packages are installed, but not their "require-dev" packages.

This actually is a good thing. If you want to contribute to an existing software package, you'd clone their repository, install everything needed for development, and are ready to contribute. But if you require that package for your own software, this is no use case to develop that particular package - it is the use case to develop your own software.

So the tl;dr: Composer only installs the development requirements of the composer.json, not of any dependencies.

like image 188
Sven Avatar answered Sep 20 '22 00:09

Sven


There is a solution for installing the require-dev packages of a vendor into your project.

https://github.com/wikimedia/composer-merge-plugin

Add this into your composer.json of your project

{
    "require": {
        "wikimedia/composer-merge-plugin": "dev-master"
    },
    "extra": {
        "merge-plugin": {
            "include": [
                "vendor/laravel/framework/composer.json"
            ]
            "recurse": true,
            "replace": false,
            "ignore-duplicates": false,
            "merge-dev": true,
            "merge-extra": false,
            "merge-extra-deep": false,
            "merge-scripts": false
        }
    }
}

It is important to have "merge-dev": true, run

composer update

And the require-dev packages of "vendor/laravel/framework/composer.json" will be installed in your project.

like image 20
Arno Avatar answered Sep 23 '22 00:09

Arno