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
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.
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 .
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With