Introduction
Optimizing local development
This section includes optional tips to optimize performance when running your Filament app locally.
If you’re looking for production-specific optimizations, check out Deploying to production.
Enabling OPcache
OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request. This can significantly speed up your local development environment, especially for larger applications.
Checking OPcache status
To check if OPcache is enabled, run:
php -r "echo 'opcache.enable => ' . ini_get('opcache.enable') . PHP_EOL;"
You should see opcache.enable => 1
. If not, enable it by adding the following line to your php.ini
:
opcache.enable=1 # Enable OPcache
TIP
To locate your php.ini
file, run: php --ini
Configuring OPcache settings
If you’re experiencing slow response times or suspect that OPcache is running out of space, you can adjust these parameters in your php.ini
file:
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
TIP
To locate your php.ini
file, run: php --ini
opcache.memory_consumption
: defines how much memory (in megabytes) OPcache can use to store precompiled PHP code. You can try setting this to128
and adjust based on your project’s needs.opcache.max_accelerated_files
: sets the maximum number of PHP files that OPcache can cache. You can try10000
as a starting point and increase if your application includes a large number of files.
These settings are optional but useful if you’re troubleshooting performance or working on a large Laravel app.
Exclude your project folder from antivirus scanning
Issues with the performance of Filament, particularly on Windows, often involve Microsoft Defender.
Security software, such as realtime file scanners or antivirus tools, can slow down your development environment by scanning files every time they’re accessed. This can affect PHP execution, view rendering, and performance in general.
If you’re noticing slowness, consider excluding your local project folder from realtime scanning.
Tools like Microsoft Defender, or similar antivirus solutions, can be configured to skip specific directories. Check your antivirus or security software documentation for instructions on how to exclude specific folders from realtime scanning.
NOTE
Only exclude folders from scanning if you fully trust the project and understand the risks.
Disabling debugging tools
Debugging tools can be very useful for local development, but they can significantly slow down your application when you aren’t actively using them. Temporarily disabling these tools when you need maximum performance can make a noticeable difference in your development experience.
Disabling view debugging in Laravel Herd
Laravel Herd includes a view debugging tool for macOS and Windows. It shows which views were rendered and what data was passed to them during a request.
While helpful for debugging, this feature can significantly slow down your app. If you’re not actively using it, it’s best to turn it off.
To disable view debugging in Herd:
- Open Herd > Dumps.
- Click Settings.
- Uncheck the “Views” option.
Disabling Debugbar
While useful for debugging, Laravel Debugbar can slow down your application, especially on complex pages, because it collects and renders a large amount of data on each request.
If you’re noticing slowness, try disabling it by adding the following line to your .env
file:
DEBUGBAR_ENABLED=false
If you still need Debugbar for development, consider disabling specific collectors you’re not using. Refer to the Debugbar documentation for details.
Disabling Xdebug
Xdebug is a powerful tool for debugging, but it can significantly slow down performance. If you notice performance issues, check if Xdebug
is installed and consider disabling it.
If Xdebug
is installed but not disabled, it will still be enabled by default. If you have it installed, make sure it is explicitly disabled in your php.ini
file:
xdebug.mode=off # Disable Xdebug
TIP
To locate your php.ini
file, run: php --ini
Caching Blade icons
Caching Blade icons can help improve performance during local development, especially in views that render many icons.
To enable caching, run:
php artisan icons:cache
Make sure that when you install new Blade icon packages, you run the command again to discover the new icons.
Edit on GitHubStill need help? Join our Discord community or open a GitHub discussion