承接 degecko/laravel-blade-inline 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

degecko/laravel-blade-inline

Composer 安装命令:

composer require degecko/laravel-blade-inline

包简介

Inline Blade partials at compile time for faster rendering in loops

README 文档

README

Inline Blade partials at compile time for faster rendering in loops.

The problem

When you use @include inside a loop, Laravel's view factory resolves the file, creates a new view instance, and compiles the template on every iteration. For a page rendering 100+ cards, this overhead adds up.

{{-- Each iteration pays the full view factory cost --}}
@foreach ($items as $item)
    @include('components.card')
@endforeach

The solution

@inline compiles the partial once and embeds the resulting PHP directly into the parent view at compile time. At runtime, the loop body is just plain PHP — no view factory, no file lookups, no ComponentAttributeBag.

{{-- Compiled once, inlined as raw PHP --}}
@foreach ($items as $item)
    @inline('components.card')
@endforeach

Benchmarks

Rendering an escort listing card across different loop sizes (Laravel 13, PHP 8.4):

Cards @include @inline Improvement
13 1.61ms 1.51ms 6%
104 13.6ms 10.1ms 26%
260 32.6ms 27.6ms 16%

The improvement grows with template complexity and loop size.

Installation

composer require degecko/laravel-blade-inline

The service provider is auto-discovered.

Usage

Basic usage

@inline works like @include but the partial shares the parent's variable scope:

@foreach ($products as $product)
    @inline('components.product-card')
@endforeach

The $product variable is available inside the partial automatically — no need to pass it explicitly.

Passing variables

You can set local variables for the partial:

@foreach ($products as $product)
    @inline('components.product-card', [
        'highlight' => $loop->first,
        'lazy' => $loop->index > 6,
    ])
@endforeach

How it works

  1. At compile time, @inline reads the partial's Blade source
  2. Strips any @props directive (unnecessary since variables come from the parent scope)
  3. Compiles the Blade to PHP via Blade::compileString()
  4. Embeds the compiled PHP directly into the parent view

The result: the partial's logic becomes part of the parent view's compiled PHP file. At runtime, there's zero overhead from view resolution.

Important notes

  • Shared scope: The partial accesses the same variables as the parent view. No isolated scope like @include.
  • No $attributes: Since @props is stripped, the $attributes bag is not available. Use explicit variables instead.
  • Cache: Changes to the partial require php artisan view:clear to take effect (same as any Blade change in production).
  • All Blade directives work: @if, @foreach, @php/@endphp, {{ }}, etc. are all fully supported.

When to use

Use @inline when:

  • A partial is rendered many times in a loop (listing pages, tables, feeds)
  • The partial doesn't need isolated variable scope
  • You want to eliminate view factory overhead

Stick with @include when:

  • The partial is rendered once or twice (no loop overhead to save)
  • You need isolated variable scope
  • You use $attributes or component features

License

MIT

degecko/laravel-blade-inline 适用场景与选型建议

degecko/laravel-blade-inline 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 7, 最近一次更新时间为 2026 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「performance」 「inline」 「laravel」 「blade」 「partial」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 degecko/laravel-blade-inline 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 degecko/laravel-blade-inline 我们能提供哪些服务?
定制开发 / 二次开发

基于 degecko/laravel-blade-inline 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-13