GithubHelp home page GithubHelp logo

dalalsunil1986 / compile-blades Goto Github PK

View Code? Open in Web Editor NEW

This project forked from te-cho/compile-blades

0.0 0.0 0.0 22 KB

For Laravel 5.* views, where i've noticed that if you nest too much views, a performance drop happens. so i built this console command based package, that flatten the view into one file for production performance improvement.

Home Page: https://packagist.org/packages/te-cho/compile-blades

License: MIT License

PHP 100.00%

compile-blades's Introduction

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

compile-blades's People

Contributors

abidulrmdn avatar mitulgolakiya avatar anirbanwgt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.