New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

te-cho/compile-blades

A Laravel package for compiling blades nested in 1 file into 1 flattened file.
1,804 63
Install
composer require te-cho/compile-blades
Latest Version:v1.0
PHP:>=5.5.9
Laravel:5
License:MIT
Last Updated:Feb 14, 2020
Links: GitHub  ·  Packagist
Maintainer: abd_rmdn

compile-blades

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:

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

test.blade.php subviews/included-test.blade.php

Output File

test.blade.php

Related Packages

holidays/holidays

supply a festival and holiday package

6 0
krisawzm/critical-css

A Laravel package for generating and using inline critical-path CSS.

14,233 46
anahkiasen/flatten

A package for the Illuminate framework that flattens pages to plain HTML

13,055 331
karlomikus/theme

Add theming support to your Laravel 5.* projects

4,403 69
fraank/view-counter

A view and like counter extension for your laravel project.

526 16

Version History

Version Released PHP Laravel License
v1.0 >=5.5.9 5.0.*|5.1.*|5.2.*|5.3.*|5.4.* MIT
v0.9 >=5.5.9 5.0.*|5.1.*|5.2.*|5.3.*|5.4.* MIT
Pre-releases (1)
Version Released PHP Laravel License
v0.9-beta >=5.5.9 5.0.*|5.1.*|5.2.*|5.3.*|5.4.* MIT