Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How can I move the Faker package from require-dev to require in my composer.json


How can I move the Faker package from require-dev to require in my composer.json


To move the Faker package from the `require-dev` section to the `require` section in your `composer.json`, follow these steps:

1. Open your `composer.json` file: Locate the `composer.json` file in the root directory of your Laravel project.

2. Find the Faker entry: Look for the Faker package entry under the `require-dev` section. It should look something like this:

json
   "require-dev": {
       "fzaninotto/faker": "^1.9"
   }
   

3. Cut the Faker entry: Remove the Faker line from the `require-dev` section.

4. Paste it into the `require` section: Add the Faker entry to the `require` section. If the `require` section does not exist, you can create it. The modified sections should look like this:

json
   "require": {
       "fzaninotto/faker": "^1.9",
       // other required packages
   },

   "require-dev": {
       // other development packages
   }
   

5. Update Composer: After making the changes, run the following command in your terminal to update Composer and install the necessary packages:

bash
   composer update
   

This command will ensure that the changes in `composer.json` are reflected in your `composer.lock` file, and the Faker package will now be available in your production environment as well[4].

Citations:
[1] https://laracasts.com/discuss/channels/laravel/upgrading-packages-best-practices?reply=892436
[2] https://stackoverflow.com/questions/40318665/how-do-i-move-some-dependecies-from-require-to-require-dev-with-composer
[3] https://www.reddit.com/r/PHPhelp/comments/ydv05d/how_to_install_requiredev_packages_from_composer/
[4] https://laraveldaily.com/tip/use-faker-outside-factories-or-seeders
[5] https://github.com/composer/composer/issues/1185