te-cho/compile-blades
Composer 安装命令:
composer require te-cho/compile-blades
包简介
A Laravel package for compiling blades nested in 1 file into 1 flattened file.
README 文档
README
A Laravel package for compiling blades nested in 1 file into 1 flattened file.
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
1) Require the package
Next, you'll need to require the package using Composer:
From your project's base path, run:
$ composer require te-cho/compile-blades
2) Configure Laravel
Service Provider
Add the following to the providers key in config/app.php:
'providers' => [ Techo\CompileBlades\CompileBladesServiceProvider::class, ];
Console
To get access to the compile:blades command, add the following to the $commands property in app/Console/Kernel.php:
protected $commands = [ \Techo\CompileBlades\Console\CompileBlades::class, ];
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 compile:blades view-name
This will generate a flattened view instead of the current one.
Example:
Lets say we have a view called test.blade.php that is called by one of our controllers, which is including another view inside of it, but the problem is that its looping in it, which causes the include to happen alot which cause performance drops. So we run the following command:
$ php artisan compile:blades test
Input File
Output File
te-cho/compile-blades 适用场景与选型建议
te-cho/compile-blades 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.8k 次下载、GitHub Stars 达 63, 最近一次更新时间为 2017 年 07 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「performance」 「compile」 「laravel」 「views」 「flatten」 「blades」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 te-cho/compile-blades 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 te-cho/compile-blades 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 te-cho/compile-blades 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
g4 application profiler package
CSS/Javascript Minificator, Compressor and Concatenator for TYPO3 - highly configurable frontend asset optimization for CSS/JS merging, minification and compression with optional body parsing, async/defer loading, inline output, data-ignore exclusions, SRI integrity validation/calculation, external
WordPress mu-plugin to remove jQuery Migrate from the list of jQuery dependencies and to allow jQuery to enqueue before </body> instead of in the <head>.
Create link to static resources with cache-breaking segment based on md5 of the file
Allows re-building materials from 3rd party libraries with patch
Production-ready Laravel Prometheus metrics package with built-in collectors for HTTP, database, cache, queue, events, errors, filesystem, and mail monitoring
统计信息
- 总下载量: 1.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 64
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-01