rubellum / slim-blade-view
Slim Framework 3 view helper built on the Blade component
Installs: 21 934
Dependents: 2
Suggesters: 0
Security: 0
Stars: 18
Watchers: 4
Forks: 7
Open Issues: 2
Requires
- illuminate/view: 5.*
- philo/laravel-blade: 3.*
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.0
- slim/slim: ^3.0
This package is auto-updated.
Last update: 2024-10-25 15:13:16 UTC
README
This is a Slim Framework view helper built on top of the Blade component.
You can use this component to create and render templates in your Slim Framework application.
Install
Via Composer
$ composer require rubellum/slim-blade-view
Requires Slim Framework 3 and PHP 5.5.0 or newer.
Usage
// Slim Settings $config = [ 'settings' => [ 'displayErrorDetails' => true, // set to false in production // Renderer settings 'renderer' => [ 'blade_template_path' => 'path/to/views', // String or array of multiple paths 'blade_cache_path' => 'path/to/cache', // Mandatory by default, though could probably turn caching off for development ], ], ]; // Create Slim app $app = new \Slim\App($config); // Fetch DI Container $container = $app->getContainer(); // Register Blade View helper $container['view'] = function ($container) { return new \Slim\Views\Blade( $container['settings']['renderer']['blade_template_path'], $container['settings']['renderer']['blade_cache_path'] ); }; // Define named route $app->get('/hello/{name}/', function ($request, $response, $args) { return $this->view->render($response, 'profile', [ 'name' => $args['name'], ]); })->setName('profile'); // Run app $app->run();
Testing
$ phpunit
License
The MIT License (MIT). Please see License File for more information.