klein0r / slim-alfred-renderer
Render Alfred XML into a PSR-7 Response object.
3.0.0
2016-01-14 23:12 UTC
Requires
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ^4.0
- slim/slim: ^3.0
README
This is a renderer for rendering Alfred 2 XML into a PSR-7 Response object. It works well with Slim Framework 3.
Installation
Install with Composer:
composer require klein0r/slim-alfred-renderer
Usage With Slim 3
use Slim\Views\ScriptFilterRenderer; include "vendor/autoload.php"; $app = new Slim\App(); $container = $app->getContainer(); $container['alfredRenderer'] = new ScriptFilterRenderer(); $app->get('/hello/{name}', function ($request, $response, $args) { $data = [ [ 'uid' => '35345345u2938475h', 'arg' => 'argument1', 'title' => 'thetitle', 'subtitle' => 'thesubtitle', 'icon' => 'icon.png', 'valid' => 'yes' ] ]; return $this->alfredRenderer->render($response, $data); }); $app->run();
Exceptions
\RuntimeException
- if template does not exist
\InvalidArgumentException
- if $data contains 'template'