There is a section about deploying a Laravel application to production in the docs.
To sum it up:
composer install --optimize-autoloader --no-dev
, note that if you still want the require-dev packages you can leave off the --no-dev
option
php artisan config:cache
php artisan route:cache
php artisan view:cache
You can read more about compiling assets here and about minification here.
Minification is the process of minimizing code and markup in your web
pages and script files. It’s one of the main methods used to reduce
load times and bandwidth usage on websites. Minification dramatically
improves site speed and accessibility, directly translating into a
better user experience. It’s also beneficial to users accessing your
website through a limited data plan and who would like to save on
their bandwidth usage while surfing the web.
You can minify your assets with Laravel Mix the following way:
Mix version 5
// Run all Mix tasks and minify output...
npm run prod
Mix version 6
// Run all Mix tasks and minify output...
npx mix --production
You can read more about the APP_ENV
environment variable here:
The current application environment is determined via the APP_ENV
variable from your .env file.
As far as I am aware this does not change much out of the box, but if you use additional third party packages or Laravel packages like for example Telescope, it determines how these packages function, for example if the APP_ENV
value is set to local
, Telescope will record all data and every user will have access to the Telescope routes.
You can see a example here and here.
php artisan optimize
– Dieldrin