Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop PHP Composer autoload require-dev library?

I use PHPUnit for testing and development only, I don't want my app to autoload them in production server, is it possible?

"require-dev": {
    "phpunit/phpunit": "4.2.*",
..

I see the file "autoload_classmap.php" contains lines such as..

return array(
    'File_Iterator' => $vendorDir . '/phpunit/php-file-iterator/File/Iterator.php',
    'File_Iterator_Facade' => $vendorDir . '/phpunit/php-file-iterator/File/Iterator/Facade.php',

Updated:

I want a clean production env and don't want to autoload phpunit, I only need phpunit during development. So, can composer generate two autoload.php so I can include them depending on my current env?

like image 403
Howard Avatar asked Dec 17 '25 18:12

Howard


1 Answers

--no-dev : Skip installing packages listed in require-dev

composer install --no-dev --optimize-autoloader

You will probably also want to do: --optimize-autoloader (-o): Convert PSR-0/4 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default.

like image 86
Alister Bulman Avatar answered Dec 19 '25 13:12

Alister Bulman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!