lionmm / compile-blades
从 te-cho/compile-blades 分支出来,将 blades 编译成新文件而不是覆盖旧文件。
1.0.1-rc1
2022-02-22 10:36 UTC
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: 2024-09-22 16:29:08 UTC
README
一个 Laravel 扩展包,用于将嵌套在 1 个文件中的 blades 编译成 1 个扁平化的文件。
仅针对 Laravel 8 进行重构和测试
准备好重构你的视图以使用此命令 ;)
为什么?
为了最佳性能,您可能想在生产环境中考虑将 blades 扁平化,因为大量的嵌套会消耗 Laravel 的时间,因为每个嵌套级别都会重复相同的管道过程,这会消耗时间和内存。
问题示例
- 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
目录
需求
本版本包仅适用于 Laravel 8+
安装
1) 需求包
从您的项目基本路径运行
$ composer require lionmm/compile-blades
2) 配置 Laravel
$ ./artisan vendor:publish --provider="Lionmm\CompileBlades\CompileBladesServiceProvider"
工作进展中
使用
在开始之前,我强烈建议您阅读 Laravel 关于视图和 blades 的文档。
扁平化视图
如果一切设置和配置正确,您要做的所有事情就是运行以下命令以扁平化特定路由或其他内容的视图
$ php artisan view:compile view.name
这将生成一个扁平化的视图而不是当前视图。
更好的方法:在配置的 auto_compilers 部分指定所需 blades 并使用命令
$ php artisan view:compile:auto
默认情况下,将创建一个名为 compiled 的文件夹在您的 resources/views 路径中,并将扁平化文件放置在其中
现在,您可以使用命令 compiled_view(); 代替 view(); 来使用扁平化视图,如果它们存在的话
工作进展中