A good package which we can use to add a new @expects directive for Laravel's Blade template engine.

laravel expect directive

Blade templates are great, but lacks a good way to define the variables it requires to work. In a normal template you must check if variables are set and/or set a default value for it.

Installation

Just install using composer and Laravel will load it automagically:

composer require vaites/laravel-blade-expects

If you don't want to use the package auto-discovery you will need to add this to the service providers in config/app.php:

'providers' => [
    // ...
    \Vaites\Laravel\BladeExpects\BladeExpectsServiceProvider::class,
]

Source Code

https://github.com/vaites/laravel-blade-expects