idealogica / good-view
Extremely simple and standard compliant view implementation of MVC pattern
1.0.4
2021-08-06 09:57 UTC
Requires
- php: >=7.1.0
- psr/http-factory: ~1.0.1
- psr/http-message: ~1.0.1
Requires (Dev)
- guzzlehttp/psr7: ~1.5.2
- idealogica/debug: ~1.1.2
- phpunit/phpunit: ~7.5.12
README
1. What is GoodView?
It is a simple MVC view implementation. By default GoodView uses PHP as template engine but it can be adapted to use any. It supports PSR-7 stream rendering so it can be easily used in HTTP middleware. GoodView supports nested views and layout views.
2. Installation
composer require idealogica/good-view:~1.0.0
3. Basic example
$viewFactory = ViewFactory::createStreamViewFactory(
new StreamFactory(),
['content' => '<div>'],
[__DIR__ . '/templates']
);
$view = $viewFactory->create('test');
$stream = $view->render(); // StreamInterface instance
$contents = $stream->getContents(); // rendered string
templates/test.phtml:
<?php $this->setLayout('layout') ?>
<?= $this->e($content); ?>
templates/layout.phtml:
!<?= trim($content) ?>!
4. License
GoodView is licensed under a MIT License.