Download the PHP package angus-mcritchie/blade-boost-directive without Composer

On this page you can find all versions of the php package angus-mcritchie/blade-boost-directive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package blade-boost-directive

Lightning-Fast Blade Components with @boost

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Adds a @boost Blade directive to your Laravel application. Caches the HTML rendered from Blade code. Optionally you can perform a simple str_replace for any variables passed to the directive.

Table of Contents

Installation

You can install the package via composer:

Signature

Parameters

Usage

The @boost directive can be used to wrap any Blade code. It will render the blade code once and cache the HTML and can optionally replace any variables passed to the directive via the second argument.

Repeating Code Use Case

A common use case would be that you're rendering a page of <x-post.card /> components which looks like this:

That is a total of 9 components per post, if we have 30 per page, that is 270 components in total and there are only 4 variables for the whole card.

Let's see how we can use the @boost directive to speed this up.

Wrapping the whole component in the @boost directive will store the HTML in the cache, then replace the passed variables with the values from the $post object and results in Blade only rendering 1 component instead of 270 🚀.

You could use the file cache store and render zero components (after the first request) but you'll need to clear the cache when you make changes to the component.

But I Have an if Statement in There!

If you want to conditionally show the badge, you'll want to update the key to include the condition so that the cache is different for each condition.

Passing the key as an array with all your conditions, @boost will join the array with a . and use that as the cache key.

Large Component Use Case

Another common use case would be that you're rendering a page with a single components with many smaller other components.

To speed this up we can use the @boost directive to cache the HTML for the footer and only render it once. By default, @boost uses the array cache store, which is the fastest cache store available but is not persistent, this use case you'll want to use the file cache store. You can do this by passing a third argument to the @boost directive.

Let's see how we can use the @boost directive to speed this up.

Now, Blade will just render this component once and store the HTML in the cache. The next time the page is loaded, the pre-rendered component will be stored in the file cache store. This is useful if you want to speed up large, but simple components that are used on every page and only rendered once.

Simple Small Repeating Use Case

Alternative syntax you can pass the key as the first parameter which is handle for simple cases where you don't need to pass any options, or you just prefer to pass the key as the first parameter.

Mind you that the @boost directive will use the Cache::rememberForever() under the hood so it's up to you to clear the cache when you make changes to the component.

Escaping

The @boost directive will escape the HTML by default using Laravel's e() function. If you want to render the HTML without escaping, you can pass the raw option to the directive. This will allow you to output raw HTML without any escaping, which can be useful in certain scenarios where you trust the content being rendered.

Cache Store

The @boost directive will prefix the cache key with the blade-boost-directive. prefix which is configurable in the config file. This is to avoid collisions with other packages or parts of your application.

If you wish to clear a specific cache key, you can use the following.

Configuration

You can publish the configuration file with the following command:

This is the contents of the published config file:

Benchmarks

Our benchmarks show the performance improvements you can expect when using the @boost directive. The benchmarks are not exhaustive and only serve as a demonstration of the performance improvements you can expect.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of blade-boost-directive with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0||^11.0||^12.0||^13.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package angus-mcritchie/blade-boost-directive contains the following files

Loading the files please wait ...