buchin/slim-blade-view

Blade for Slim Framework 3 with Custom Directive
20,492 2
Install
composer require buchin/slim-blade-view
Latest Version:0.1.1
License:MIT
Last Updated:Jan 11, 2017
Links: GitHub  ·  Packagist
Maintainer: buchin

Blade for Slim Framework 3

Usage

In index.php set up the blade container:

$container = $app->getContainer();
$blade = new \Slim\Views\Blade(
    '/path/to/views/folder',
    '/path/to/cache/folder'
);

// [optional] insert custom directive here

$container['blade'] = $blade;

Example code to render index.blade.php in route:

return $this->blade->render($response, 'index', $args);

Advanced: Custom directive:

$container = $app->getContainer();
$blade = new \Slim\Views\Blade(
    '/path/to/views/folder',
    '/path/to/cache/folder'
);

// example directive here, usage: @helloWorld
$blade->getRenderer()->getCompiler()->directive('helloWorld', function(){

    return "<?php echo 'Hello World'; ?>";
});

$container['blade'] = $blade;

$app->run();

If you like to build custom directive using $app:


$app->getContainer()['blade']->getRenderer()->getCompiler()->directive('helloWorld', function(){

    return "<?php echo 'Hello My Second World'; ?>";
});

Related Packages

rubellum/slim-blade-view

Slim Framework 3 view helper built on the Blade component

23,130 18
jenssegers/blade

The standalone version of Laravel's Blade templating engine for use outside of L...

1,397,852 859
eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

11,038,022 829
pragmarx/steroids

Laravel 4 Blade on Steroids

205 94
atijust/ronin-blade

Laravel Blade template engine as a standalone component

21 0

Version History

Version Released Laravel License
0.1.1 5.* MIT
0.1 5.* MIT