When deploying to production, make sure that you are optimizing Composer's class autoloader map so Composer can quickly find the proper file to load for a given class:
composer install --optimize-autoloader --no-dev
In addition to optimizing the autoloader, you should always be sure to include a
composer.lockfile in your project's source control repository. Your project's dependencies can be installed much faster when a
composer.lockfile is present.
Optimizing Configuration Loading
When deploying your application to production, you should make sure that you run the
config:cache CLI command during your deployment process:
php artisan config:cache
This command will combine all configuration files into a single cached file, which greatly reduces the number of trips the framework must make to the filesystem when loading your configuration values.
If you execute the
config:cachecommand during your deployment process, you should be sure that you are only calling the
envfunction from within your configuration files. Once the configuration has been cached, the
.envfile will not be loaded and all calls to the
envfunction will return
Optimizing Route Loading
If you are building a large application with many routes, you should make sure that you are running the
route:cache CLI command during your deployment process:
php artisan route:cache
This command reduces all of your route registrations into a single method call within a cached file, improving the performance of route registration when registering hundreds of routes.
Since this feature uses PHP serialization, you may only cache the routes for applications that exclusively use controller based routes. PHP is not able to serialize Closures.
When possible it is advised to enable HTTP cache from the Settings module. This will cache applicable requests for a specified TTL and bypass your application entirely on subsequent requests, greatly improving response times and resources needed for high load applications.
When possible it is advised to enable database cache from the Settings module. Doing so will allow PyroCMS to intelligently manage database level cache for you. This feature, by default, does not require any special code considerations.