PHP code example of vaites / laravel-blade-expects

1. Go to this page and download the library: Download vaites/laravel-blade-expects library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vaites / laravel-blade-expects example snippets


'providers' => [
    // ...
    \Vaites\Laravel\BladeExpects\BladeExpectsServiceProvider::class,
]
blade
@props(['title', 'description' => 'Default text'])
blade


if(!isset($type))
{
    $type = 'boxed';
}

` or `<?=` tags are detected.

## How it works

The directive is parsed in two ways:

* Like a closure to extract its parameters
* Like a PHP block to parse wrapped phpDoc 

The resulting definition tells what to do:

* If the parameter has no default value, the variable is s translated in simple PHP conditionals placed in the compiled template. 

Exceptions thrown are:

* `\Vaites\Laravel\BladeExpects\Exceptions\PhpTagsNotAllowedException`
* `\Vaites\Laravel\BladeExpects\Exceptions\UndefinedVariableException`
* `\Vaites\Laravel\BladeExpects\Exceptions\WrongTypeException`
* `\Vaites\Laravel\BladeExpects\Exceptions\WrongClassException`

All variables inherit from `\Vaites\Laravel\BladeExpects\Exceptions\Exception` that inherits from 
`InvalidArgumentException`.

## Requirements

* Laravel 5.5 or greater
* PHP 7.2 or greater

## Installation

Just install using `composer` and Laravel will load it _automagically_:



If you don't want to use the [package auto-discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518)
you will need to add this to the service providers in `config/app.php`:



## Configuration

The following environment variables can be defined:

* `BLADE_EXPECTS_ENABLED`: boolean, enable or disable the directive (tags are stripped)
* `BLADE_EXPECTS_PHP_TAGS`: boolean, enable or disable the use of PHP tags 

## PhpStorm integration

The PhpStorm IDE can recognize the custom Blade directive if is set in *File > Settings > Languages & Frameworks > PHP >
Blade > Directives* by adding a new one with the following properties:

 * Name: expects
 * Has parameters: check
 * Prefix:  function(
 * Suffix: ){};