PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 9, 2022

[FIXED] Composer won't install "require-dev" packages

 February 09, 2022     composer-php     No comments   

Issue

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

Solution

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.



Answered By - Sven
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing