6 Tips for optimizing a laravel application

Today, I would like to share about some tips for optimizing a laravel application. Let’s take a look.

1. Cache routes, config and views

Caching speeds up your application. This is important when deploying a application to a production environment.

To cache your routes, you can use the following command:
php artisan route:cache

To clear the route cache, you can use the following command:
php artisan route:clear

To cache config, you can use the following command:

php artisan config:cache

To cache your views, you can use the following command:

php artisan view:cache

2. Remove unused services

You should remove unused services when the application grows. This can be done by removing the service from the config/app.php file.

3. Remove unused packages

To keep the app clean, you should remove unused packages from the application. This can be done by removing the package from the composer.json file or by running the following command:

composer remove package-name

4. Remove development dependencies

You should also remove development dependencies when deploying to production. This can be done by running the following command:

composer install –prefer-dist –no-dev -o

5. Composer Autoload Optimization

For your applications, you should use the composer autoload optimization feature as the autoloader can take significant time for each request:

composer dumpautoload -o

The -o flag will convert PSR-0/4 autoloading to classmap to become a faster autoloader.

6. Precompile your assets

If npm is used for your front-end development, you should precompile your assets. This can be done by running the following command:

npm run production

This will compile the assets and create public/assets directory.

This is all for now. Hope you enjoy that.

By Asahi



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム