PHPackages                             degecko/laravel-blade-inline - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. degecko/laravel-blade-inline

ActiveLibrary[Templating &amp; Views](/categories/templating)

degecko/laravel-blade-inline
============================

Inline Blade partials at compile time for faster rendering in loops

1.2.0(1mo ago)71MITPHPPHP ^8.2CI passing

Since Apr 13Pushed 1mo agoCompare

[ Source](https://github.com/degecko/laravel-blade-inline)[ Packagist](https://packagist.org/packages/degecko/laravel-blade-inline)[ RSS](/packages/degecko-laravel-blade-inline/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Laravel Blade Inline
====================

[](#laravel-blade-inline)

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

The problem
-----------

[](#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
------------

[](#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
----------

[](#benchmarks)

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

Cards`@include``@inline`Improvement131.61ms1.51ms6%10413.6ms10.1ms**26%**26032.6ms27.6ms**16%**The improvement grows with template complexity and loop size.

Installation
------------

[](#installation)

```
composer require degecko/laravel-blade-inline
```

The service provider is auto-discovered.

Usage
-----

[](#usage)

### Basic 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

[](#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

[](#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
---------------

[](#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
-----------

[](#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
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance89

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

56d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5130992?v=4)[Cosmin Gheorghita](/maintainers/degecko)[@degecko](https://github.com/degecko)

---

Top Contributors

[![degecko](https://avatars.githubusercontent.com/u/5130992?v=4)](https://github.com/degecko "degecko (6 commits)")

---

Tags

laravelperformancebladeinlinepartial

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/degecko-laravel-blade-inline/health.svg)

```
[![Health](https://phpackages.com/badges/degecko-laravel-blade-inline/health.svg)](https://phpackages.com/packages/degecko-laravel-blade-inline)
```

###  Alternatives

[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k531.0k21](/packages/robsontenorio-mary)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5222.7k](/packages/hasinhayder-tyro-dashboard)[technikermathe/blade-lucide-icons

A package to easily make use of Lucide icons in your Laravel Blade views.

18379.7k9](/packages/technikermathe-blade-lucide-icons)[hasinhayder/tyro-login

Tyro Login - Beautiful, customizable authentication views for Laravel 12 &amp; 13

2443.7k5](/packages/hasinhayder-tyro-login)[ublabs/blade-simple-icons

A package to easily make use of Simple Icons in your Laravel Blade views.

1958.8k](/packages/ublabs-blade-simple-icons)[yocmen/html-minify

Minifies the HTML output of Laravel 5 applications (Originally from https://github.com/fitztrev/laravel-html-minify)

1613.7k](/packages/yocmen-html-minify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
