composer install --dev is gone, how do I use dev dependencies? - composer-php

Most people in my team doesn't need dev dependencies. So it is desirable that composer install doesn't install dev dependencies.
However, QA does need to install them with some command.
I have no idea how to achieve this now. Formerly it was composer install --dev but that's gone.

You can set the environment variable COMPOSER_NO_DEV to 0 or 1 to change the default behaviour of composer install and composer update.
see: documentation - COMPOSER_NO_DEV
If you want composer install to not install the dev dependencies by default
export COMPOSER_NO_DEV=1
If you want composer install to install dev dependencies (the default)
export COMPOSER_NO_DEV=0
or unset COMPOSER_NO_DEV
Depending on how you develop (i.e. in a container) there are various options to set a default value for the environment variable.
On the other hand you can instruct your engineer colleagues that do not require any dev dependencies to run the command:
composer install --no-dev
# .. or ..
COMPOSER_NO_DEV=1 composer install
... instead of ...
composer install
# .. or ..
COMPOSER_NO_DEV=0 composer install

Related

Composer install VS composer install --dev

Is there any differences between "composer install" and "composer install --dev"?
I ran these two commands and get the same packages installed.
As you can read in the documentation, leaving it out and using --dev performs the same action:
--dev: Install packages listed in require-dev (this is the default behavior).

how to install illuminate/mail via composer in Lumen

A setting mail-in on lumen project, I should install illuminate\mail via composer, but show me an error:
Your requirements could not be resolved to an installable set of packages
You can install through composer using the following command in the terminal:
composer require illuminate/mail
Make sure you are in the project directory.

How do I do updates for my laravel project?

What command can I use to see a list of all my installed packages and do the update ? (through the terminal)
If you have composer run in the console
composer show --installed
For updating all your dependencies run in the console
composer update
To show installed packages run: composer show --installed
To update installed packages run: composer update
And Read these documents this and this

How to get the required version of the Composer Plugin API?

It is necessary to do the following:
composer self-update
composer global require "fxp/composer-asset-plugin:*"
But after executing the composer self-update, an error pops up:
The "hirak/prestissimo" plugin was skipped because it requires a Plugin API version ("~1.0.0-alpha10") that does not match your Composer installation ("1.1.0"). You may need to run composer update with the "--no-plugins" option.
My current version of Composer is 1.4.2
For the same reason, the following commands do not work:
composer global require "fxp/composer-asset-plugin:*"
An error pops up:
The "hirak/prestissimo" plugin was skipped because it requires a Plugin API version ("~1.0.0-alpha10") that does not match your Composer installation ("1.1.0"). You may need to run composer update with the "--no-plugins" option.
How to get the required version of the Composer Plugin API?
You just need to update hirak/prestissimo:
composer global update hirak/prestissimo --no-plugins

What does the different flags of Composer when creating a Laravel project?

Anyone can tell me the difference between this commands
composer create-project laravel/laravel your-project-name --prefer-dist
composer create-project laravel/laravel your-project-name
composer create-project laravel/laravel your-project-name -dev
From the documentation for composer:
--prefer-dist: Reverse of --prefer-source, composer will install from dist if possible. This can speed up installs substantially on build servers and other use cases where you typically do not run updates of the vendors. It is also a way to circumvent problems with git if you do not have a proper setup.
That means Composer will install the dependencies from the distribution build, instead of the sources.
And for the --dev flag:
--dev: Install packages listed in require-dev.
That means Composer will also install all package dependencies list in require-dev key from your composer.json. The require-dev key are dependences only required for development.
Please, for more information, read the docs regarding Composer CLI: https://getcomposer.org/doc/03-cli.md#create-project

Resources