lionmm/compile-blades

Fork of te-cho/compile-blades to compile blades into a new file instead of overwriting the old file.

1.0.1-rc1 2022-02-22 10:36 UTC

This package is auto-updated.

Last update: 2024-04-22 15:44:22 UTC


README

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

Refactored and tested only for Laravel 8

Be ready to refactor your views for using this command ;)

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

Requirements

This version of package working only with Laravel 8+

Installation

1) Require the package

From your project's base path, run:

    $ composer require lionmm/compile-blades

2) Configure Laravel

    $ ./artisan vendor:publish --provider="Lionmm\CompileBlades\CompileBladesServiceProvider"

WIP

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 view:compile view.name

This will generate a flattened view instead of the current one.

Better way: pic needed blades in auto_compilers section of configuration and use command

    $ php artisan view:compile:auto

By default, folder compiled will be created in your resources/views path and flatten files will be placed in it

Now you can use command compiled_view(); instead of view(); for using flatten views IF they present

WIP