Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - What steps should one take to make a Laravel app ready for production mode

The scenario is I have developed a Laravel app in my localhost. Everything works fine. Now I need to make it go online. I am just trying to figure out what steps (configuration , security etc.) should I take before I make it go online.

I am listing a few steps:

1) Change in .env file to make the environment point to production mode using APP_ENV=production.

2) Avoide showing errors directly in pages as that would expose the innards of the app. Enable error logging instead.

3) Use caching for faster user experience 4) building a nice 404, not found page

What else should I undertake to turn the app from development mode into production mode ?

like image 893
Istiaque Ahmed Avatar asked Jan 09 '20 12:01

Istiaque Ahmed


People also ask

Who uses Laravel in production?

BBC, which is the oldest broadcasting organization and the largest broadcaster in the world by the number of employees, is one of the most prominent examples. A few other big companies using Laravel includes 9GAG, Pfizer, TourRadar, and Crowdcube.

Can I create an app with Laravel?

You can manage and create any number of storefronts, including apps and devices, using the Laravel eCommerce GraphQL-based Rest API. It decouples a website's front-end from its back-end, allowing developers to use any front-end technology of their choice, such as javascript frameworks such as react.


2 Answers

  1. Apply changes to .env file:
    • APP_ENV=production
    • APP_DEBUG=false
  2. Make sure that you are optimizing Composer's class autoloader map (docs):
    • composer dump-autoload --optimize
    • or along install: composer install --optimize-autoloader --no-dev
    • or during update: composer update --optimize-autoloader
  3. Optimizing Configuration Loading:

    • php artisan config:cache
  4. Optimizing Route Loading

    • php artisan route:cache
  5. Compile all of the application's Blade templates:
    • php artisan view:cache
  6. Cache the framework bootstrap files:

    • php artisan optimize
  7. (Optional) Compiling assets (docs):

    • npm run production
  8. (Optional) Generate the encryption keys Laravel Passport needs (docs):

    • php artisan passport:keys
  9. (Optional) Start Laravel task scheduler by adding the following Cron entry (docs):

    • * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
  10. (Optional) Install, config and start the Supervisor (docs):

  11. (Optional) Create a symbolic link from public/storage to storage/app/public (docs):
    • php artisan storage:link

  • Laravel deployment docs: https://laravel.com/docs/master/deployment
  • Digital Ocean's tutorial: How to Install and Configure Laravel
like image 72
Hafez Divandari Avatar answered Oct 21 '22 03:10

Hafez Divandari


There are some steps you can check

  1. Install LEMP or LAMP stack.
  2. You can check/add PHP and Dependencies for Laravel
  3. Test Your Site’s Functionality
  4. Optimize Image Size
  5. Google Analytics & SEO addition
  6. Check w3 validation
  7. Page speed optimization
like image 24
Md Asaduzzaman Avatar answered Oct 21 '22 05:10

Md Asaduzzaman