Before going to understand the difference between require and require_dev first understand what is require and require_dev.
require: These are must packages for the code to run. It defines the actual dependency as well as package version.
require_dev: It defines the packages necessary for developing the project and not needed in production environment.
Note: The require and require_dev are important parameters available in composer.json.
What is composer?
Composer is dependency/parameter manager in php. It can be used to install keep a track of and update project dependency. Composer also takes care of autoload of dependencies that application relies on letting easily use the dependency inside the project without worrying about including them at the top of any given file. Dependency for project are listed within a “composer.json” file which typically located in the project root. This file holds the information about required version of packages for production and development. This file can be edited manually using any text editor or automatically through the command line via command such as “composer require ” or “composer require_dev .
To start using composer in the project first need to create composer.json file. It can be either created manually or simply run composer init. After run composer init in the terminal it will ask some basic information about the project such as package name, description (it is optional), Author and source other information like minimum stability, license and required package.
The require key in the composer.json specifies composers which packages the project depends on require takes an object that maps package names
In the above example “composer/composer” specifies vendor name and project name separated by slash (‘/’) and “1.2.*” specifies the version name.
To install the dependency need to run the composer install command and then it will find the defined package that method for supplied version constraints and download it into vendor directory. It convention to put third party code into directory named vendor. The installed command also created a composer.lock file.
Difference Between require and require_dev:
- It define actual dependency as well as package version.
- The require lists the package require by this package.
- The package will not be installed unless those requirements can be met.
- It define the packages necessary for developing project.
- The require_dev lists packages required for developing this package, or running tests, etc.
- The dev requirements of the root package are installed by default. Both install or update support the “–no-dev” option that prevents dev dependencies from being installed.
- Difference between node.js require and ES6 import and export
- PHP | (Include and Require)
- Scala | Preconditions(assert, assume, require, ensuring)
- Difference and Similarities between PHP and C
- Difference between try-catch and if-else statements in PHP
- Difference between isset() and array_key_exists() Function in PHP
- What is the difference between the | and || or operator in php?
- What is the difference between public, private, and protected in PHP?
- What is the difference between HTTP_HOST and SERVER_NAME in PHP?
- What is the difference between is_a() function and instanceof in PHP?
- What is the difference between echo, print, and print_r in PHP?
- What is the difference between array_merge and array + array in PHP?
- What is the difference between a language construct and a “built-in” function in PHP ?
- Difference between “!==” and “==!” in PHP
- Difference between array() and  in PHP
- What is the difference between single-quoted and double-quoted strings in PHP?
- Difference between break and continue in PHP
- What is the difference between Perl and PHP ?
- Difference Between JSP and PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.