lionmm / compile-blades
Fork of te-cho/compile-blades to compile blades into a new file instead of overwriting the old file.
Requires
- php: ^7.3|^8.0
- illuminate/console: ^8.0|^9.0
- illuminate/contracts: ^8.0|^9.0
- illuminate/support: ^8.0|^9.0
- illuminate/view: ^8.0|^9.0
- symfony/process: ^5.1|^6.0
Requires (Dev)
- mockery/mockery: ^1.3.1
- phpunit/phpunit: ^8.4|^9.0
This package is auto-updated.
Last update: 2025-01-22 17:07:19 UTC
README
A Laravel package for compiling blades nested in 1 file into 1 flattened file.
Refactored and tested only for Laravel 8
Be ready to refactor your views for using this command ;)
Why?
For best performance, you may want to consider flattening your blades on production, cause a lot of nesting consumes time in laravel since each nested level repeats the same pipline process, that consumes time & memory.
Example of problems:
- https://stackoverflow.com/questions/30673129/laravel-blades-performance/44863712#44863712
- https://laracasts.com/discuss/channels/laravel/how-to-improve-laravel-views-performance-when-using-multiple-times-same-view-file-or-howto-avoid-repeating-expensive-read-file-operation
Table of Contents
Requirements
This version of package working only with Laravel 8+
Installation
1) Require the package
From your project's base path, run:
$ composer require lionmm/compile-blades
2) Configure Laravel
$ ./artisan vendor:publish --provider="Lionmm\CompileBlades\CompileBladesServiceProvider"
WIP
Usage
Before getting started, I highly recommend reading through Laravels documentation on Views and Blades.
Flattening Views:
Providing everything is set up and configured properly, all you need to do in order to flatten a view for a certain route or something else, is running the following command:
$ php artisan view:compile view.name
This will generate a flattened view instead of the current one.
Better way: pic needed blades in auto_compilers
section of configuration and use command
$ php artisan view:compile:auto
By default, folder compiled
will be created in your resources/views
path and flatten files will be placed in it
Now you can use command compiled_view();
instead of view();
for using flatten views IF they present
WIP