Blade is a simple, yet powerful templating engine provided for the Slim Framework
clickcoder/slim-blade is a Laravel package for blade is a simple, yet powerful templating engine provided for the slim framework.
It currently has 32 GitHub stars and 4.669 downloads on Packagist.
Install it with composer require clickcoder/slim-blade.
Discover more Laravel packages by clickcoder
or browse all Laravel packages to compare alternatives.
Last updated
Blade is the default template engine of Laravel. The main advantage of Blade is template inheritance whilst using plain PHP. This package allows you to use Blade within the Slim Framework.
The package can be installed via Composer by requiring the "clickcoder/slim-blade": "dev-master" package in your project's composer.json.
{
"require": {
"clickcoder/slim-blade": "dev-master"
}
}
Then run the following composer command:
$ php composer.phar install
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim(array(
'view' => new \Slim\Views\Blade(),
'templates.path' => './templates',
));
To use Blade cache do the following:
$view = $app->view();
$view->parserOptions = array(
'debug' => true,
'cache' => dirname(__FILE__) . '/cache'
);
You can use all blade features as described in the Laravel 4 documentation: http://laravel.com/docs/templates#blade-templating
Create the following index.php file
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim(array(
'view' => new \Slim\Views\Blade(),
'templates.path' => './templates',
));
$view = $app->view();
$view->parserOptions = array(
'debug' => true,
'cache' => dirname(__FILE__) . '/cache'
);
$app->get('/hello/:name', function ($name) use ($app) {
$app->render('master', array(
'variable' => "Hello, $name"
));
});
$app->run();
Create a templates folder and add this inside
<!DOCTYPE html>
<html lang="en">
<body>
{{ $variable }}
</body>
</html>
visit /index.php/hello/world
MIT Public License