Deployment to production

Published 5 days ago by marcosdipaolo

Hi there. I'm about to deploy to production and I read in Laravel's docs that three lines should be ran.

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

php artisan config:cache

php artisan route:cache

Since I'd like to keep working further in the app after deployment, my question is if i can continue working in dev mode in the app once those lines are executed, or do i have to rollback the app to some previous state ???

Nakov
Nakov
4 days ago (39,850 XP)

You should use local environment to develop and then a server as a production environment. So there will be nothing stoping you to keep working in dev mode.

I am not sure if you need all of the commands that you have listed to be ran on production. But for sure you will need to install the composer dependencies, generate a key and run the migrations if you use database.

D9705996
D9705996
4 days ago (121,180 XP)

@marcosdipaolo - i strongly recommend running the commands you listed when deploying to prodauction as they optimise you application settings for routes and configuration as these don't change on a live site.

Just make sure that you set the settings in your .envto match your production setup, especially

APP_ENV=production
APP_DEBUG=false
APP_URL=http://your site.com

If you don't your links won't work if you use the route helpers and you will show full error messages if you application throws any error. Setting APP_ENV to production will also make some dangerous artisan commands prompt you if you are sure you want to do this e.g. if you try and migrate your database.

You also want to ensure if You are using laravel mix for your JavaScript that You run npm run prod to compile your scripts and css for production I.e. minifies your code for smaller files amongst other things

Please sign in or create an account to participate in this conversation.