This is a simple script to speed up Laravel Blade templates with lots of @includes.
The idea is to remove the overhead from creating a new View
by instead directly calling
PHP's require()
. This can significantly speed up big Blade templates, that are constructed
from lots of different small pieces, for templates with 1000+ includes it can make rendering
up to 4x faster.
Usage:
php php artisan view:flatten
To reset the flattened views, you can run:
php php artisan view:cache
Advantages:
- more speed
- variables behave like they would with normal @includes
Disadvantages:
- Exceptions will not directly log the file and line number in the template where they were thrown
- Views won't automatically recompile when the source file changes