2017 © Pedro Peláez
 

library viper-blade

A package enabling the use of Blade templating engine in PHP

image

arsengoian/viper-blade

A package enabling the use of Blade templating engine in PHP

  • Sunday, February 11, 2018
  • by arsengoian
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 2 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 43 % Grown

The README.md

Blade for Viper Framework

A Blade templating language adaptation for the Viper Framework, (*1)

For Blade doc, refer to the official Laravel documentation on Blade, (*2)

Usage

May be used from the controller like this:, (*3)

namespace App\Controllers;

use Viper\Core\Routing\Controller;
use Viper\Core\Routing\Methods\GET;
use Viper\Core\Viewable;
use Blade\View;
use App\Models\Client;

class HomeController extends Controller implements GET
{

    public function get (...$args): ?Viewable
    {
        $clients = Client::all();
        return new BladeView('test', [
            'folks' => $clients,
        ]);
    }

}

Exception reporting

Exceptions may be parsed nicely in a custom view. By default, the error.blade.php is invoked with $e variable for exception, (*4)

use \Blade\View::bindErrorView() for configuration, (*5)

Setup

Extra variables and error preferences may be passed from a filter (official doc on filters):, (*6)

namespace App\Filters;

use Blade\View;
use Viper\Core\Filter;

class BladeFilter extends Filter
{

    public function proceed ()
    {
        // Set up custom error reporting
        if (!Config::get('DEBUG'))
            View::bindErrorView('publicErrorView', 'exception');

        // These variables will be visible in all the views
        View::propagateVars([
            'myCustomVar' => 42,
            'clientHandler' => Config::get('Clients.HANDLER'),
        ]);
    }
}

The Versions

11/02 2018

dev-master

9999999-dev

A package enabling the use of Blade templating engine in PHP

  Sources   Download

Apache-2.0

The Requires

 

by Arsen Goian

framework blade viper