Reputation: 4210
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
Upvotes: 21
Views: 18806
Reputation: 70863
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.
Upvotes: 39
Reputation: 1359
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.
Upvotes: 5