2017 © Pedro Peláez
 

library compile-blades

A Laravel package for compiling blades nested in 1 file into 1 flattened file.

image

te-cho/compile-blades

A Laravel package for compiling blades nested in 1 file into 1 flattened file.

  • Sunday, August 6, 2017
  • by abd_rmdn
  • Repository
  • 3 Watchers
  • 35 Stars
  • 39 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 2 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

compile-blades

A Laravel package for compiling blades nested in 1 file into 1 flattened file., (*1)

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., (*2)

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, (*3)

Table of Contents, (*4)

1) Require the package

Next, you'll need to require the package using Composer:, (*5)

From your project's base path, run:, (*6)

$ composer require te-cho/compile-blades

2) Configure Laravel

Service Provider

Add the following to the providers key in config/app.php:, (*7)

``` php 'providers' => [ Techo\CompileBlades\CompileBladesServiceProvider::class, ];, (*8)


#### Console To get access to the `compile:blades` command, add the following to the `$commands` property in `app/Console/Kernel.php`: ``` php protected $commands = [ \Techo\CompileBlades\Console\CompileBlades::class, ];

Usage

Before getting started, I highly recommend reading through Laravels documentation on Views and Blades., (*9)

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:, (*10)

$ php artisan compile:blades view-name

This will generate a flattened view instead of the current one., (*11)

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:, (*12)

$ php artisan compile:blades test

Input File

test.blade.php subviews/included-test.blade.php, (*13)

Output File

test.blade.php, (*14)

The Versions

06/08 2017

dev-master

9999999-dev

A Laravel package for compiling blades nested in 1 file into 1 flattened file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abidul Wahab Ramadan

laravel performance views compile flatten blades

06/08 2017

v1.0

1.0.0.0

A Laravel package for compiling blades nested in 1 file into 1 flattened file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abidul Wahab Ramadan

laravel performance views compile flatten blades

06/08 2017

v0.9

0.9.0.0

A Laravel package for compiling blades nested in 1 file into 1 flattened file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abidul Wahab Ramadan

laravel performance views compile flatten blades

06/08 2017

v0.9-beta

0.9.0.0-beta

A Laravel package for compiling blades nested in 1 file into 1 flattened file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abidul Wahab Ramadan

laravel performance views compile flatten blades

01/07 2017

dev-dev

dev-dev

A Laravel package for compiling blades nested in 1 file into 1 flattened file.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abidul Wahab Ramadan

laravel performance views compile flatten blades