diff --git a/doc/book/application-integration/stand-alone.md b/doc/book/application-integration/stand-alone.md new file mode 100644 index 00000000..a5627ea3 --- /dev/null +++ b/doc/book/application-integration/stand-alone.md @@ -0,0 +1,69 @@ +# Stand-Alone + +The view and all view-helpers of zend-view can also be used stand-alone. + +## The View + +### Setup + +[Create the a renderer, set a resolver for templates](../php-renderer.md#usage) +and initialize the view, e.g. `public/index.php`: + +```php +// Create template resolver +$templateResolver = new Zend\View\Resolver\TemplatePathStack( + [ + 'script_paths' => [__DIR__ . '/../view'], + ] +); + +// Create the renderer +$phpRenderer = new Zend\View\Renderer\PhpRenderer(); +$phpRenderer->setResolver($templateResolver); + +// Initialize the view +$view = new Zend\View\View(); +$view->getEventManager()->attach( + Zend\View\ViewEvent::EVENT_RENDERER, + function () use ($phpRenderer) { + return $phpRenderer; + } +); +``` + +### Create View Script + +[Create a view script](../view-scripts.md), e.g. `view/index.phtml`: + +```php +