Ebextension setting when releasing a Laravel application to Elastic Beanstalk

Aug 31, 2020 PHP Laravel ElasticBeanstalk

When you release Laravel in production, using a config cache or a route cache will make it run more efficiently and improve the response of your application.

When releasing to Elastic Beanstalk, you can add the command at the time of release by putting a .config file in .ebextensions/*.

container_commands:
   01-cache_config:
     command: "php artisan config:cache"
   02-cache_route:
     command: "php artisan route:cache"
   03-cache_view:
     command: "php artisan view:cache"

With the above, cache of config, route and view can be generated after uploading the application. container_commands are executed before restarting the Apache server.