Download the PHP package bhuvidya/laravel-blade-helper without Composer

On this page you can find all versions of the php package bhuvidya/laravel-blade-helper. 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 laravel-blade-helper

Laravel Blade Helper

License Total Downloads Latest Stable Version Latest Unstable Version

A Laravel 5 package to ease the creation of Blade directives.

Please note that this package was tested on Laravel 5.6. It should work on >=5.5, but I cannot guarantee it will work on earlier versions. Sorry.

BIG KUDOS to Liam (https://github.com/ImLiam) who proposed this as a pull request on the Laravel Framework (https://github.com/laravel/framework/pull/24923). I really liked the concept so I put his code into a package for others to use if they wanna. This README draws on his explanations in the pull request.

Installation

Add bhuvidya/laravel-blade-helper to your app:

$ composer require "bhuvidya/laravel-blade-helper"

If you're using Laravel 5.5 or higher, you don't have to edit app/config/app.php.

Otherwise, edit app/config/app.php and add the service provider:

'providers' => [
    'BhuVidya\BladeHelper\BladeHelperServiceProvider',
]

Configuration

The package comes with its own configuration file, which you can install and tweak in your application:

This will install the config file to your app's config directory. It's contents are:

As you can see, it's possible to customise the service container instance name, and (probably a bit more useful), get the facade to be loaded automatically, and with your own class name if so desired.

Usage

Basically this helper provides a neat level of abstraction to the "define a custom Blade directive" process. It's benfit is in allowing the connected function (or closure) to have a well-defined parameter list, without having to do the cruft coding around parsing the raw expression string passed in from Laravel core. This allows you to quickly turn an external function into a Blade directive.

For example, to turn the php function join into a directive:

Admittedly a contrived example, but it gives you the idea.

The second argument can also take a callback. The advantage of a callback here over the Blade::directive(...) method is that the closure can have specific parameters defined instead of just the raw expression passed through. This has several good things that solve a previous idea Liam brought up:

By default, all of the helper directives will echo out their contents to the view when used. This can be disabled by passing false as the third argument.

In the pull request there was some discussion around whether directives should be used just for code structure, and not presentation. Personally I like custom directives even for "presentation" or "convenience" usage because:

  1. It makes template files cleaner, and easier to read
  2. Having the code in one place makes it easier to change in the future

As a last example, here is a wrapper for the logic around a FontAwesome 4 icon. There's a bit of boilerplate around it you probably don't want to remember to write every time, and you wouldn't want to @include it every time. While it could be a regular function and operate just the same, this is one of those things you'd probably want that bit of syntactic sugar around because of how often it can be used - nor would there be any advantage of it being a regular function or helper as you'd never get any use of it outside views. Also, if you ever decided to tweak the html of the <i> element (maybe adding a new aria attribute), then you only have to do it in one place.


All versions of laravel-blade-helper with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
laravel/framework Version ~5.5.0|~5.6.0|~5.7.0
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 bhuvidya/laravel-blade-helper contains the following files

Loading the files please wait ....