1

What Composer and Artisan commands are necessary to run during deployment of a brand new Laravel application? Per Laravel 5.7 documentation, are these the only essential commands?

composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
  • 1
    Depending on your app and how much you use cacheing, clearing views and caches could have a big impact on performance. I think those are best left out of your automatic process, and only run when needed. – Jeff Oct 08 '18 at 21:39
  • @Jeff what do you mean only run when needed? If an app has its views or configs cached, when would they be refreshed? I think the only way is to include them in deployment (as fresh code could change the views and configs, so they need refreshing) – Paras Oct 08 '18 at 21:42

1 Answers1

2

Methods are:

composer install --optimize-autoloader --no-dev
composer dump-autoload

The others are optional.

  1. Do you cache your configs? If yes, include php artisan config:cache
  2. Do you cache your routes? If yes, include php artisan route:cache
  3. Do you cache your views? If yes, include php artisan view:cache
  4. Do you want to flush your app cache every time you deploy? If yes, include php artisan cache:clear

Beware that flushing your app cache could have many undesirable effects, especially if you're using your cache system for sessions, queues, etc. as it would clear out everything

Paras
  • 9,258
  • 31
  • 55
  • Both of those commands generate optimized autoload files. These two run at the same time seem somewhat redundant. – Karl Hill Oct 10 '18 at 01:01
  • Yours. composer install --optimize-autoloader --no-dev composer dump-autoload – Karl Hill Oct 10 '18 at 05:54
  • No they are not the same command. You can refer composer's documentation. The first one optimizes autoload files and the second one clears them out. – Paras Oct 10 '18 at 05:56
  • If you run them back to back... > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover Discovered Package: bensampo/laravel-enum Discovered Package: binarytorch/larecipe Discovered Package: fideloper/proxy Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Package manifest generated successfully. – Karl Hill Oct 10 '18 at 05:57
  • I see. Just checked composer.json, Laravel triggers the second through a hook. Yes in that case you can skip the second one – Paras Oct 10 '18 at 05:59