https://github.com/codemonster-ru/view
View rendering core for PHP applications
https://github.com/codemonster-ru/view
engine php renderer templating view
Last synced: 6 months ago
JSON representation
View rendering core for PHP applications
- Host: GitHub
- URL: https://github.com/codemonster-ru/view
- Owner: codemonster-ru
- License: mit
- Created: 2025-09-26T09:29:41.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-12-27T11:29:09.000Z (6 months ago)
- Last Synced: 2025-12-28T18:19:28.664Z (6 months ago)
- Topics: engine, php, renderer, templating, view
- Language: PHP
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# codemonster-ru/view
[](https://packagist.org/packages/codemonster-ru/view)
[](https://packagist.org/packages/codemonster-ru/view)
[](https://packagist.org/packages/codemonster-ru/view)
[](https://github.com/codemonster-ru/view/actions/workflows/tests.yml)
A core for rendering views in PHP applications.
The package itself doesn't contain any engines; they are included in separate packages:
- [`codemonster-ru/view-php`](https://github.com/codemonster-ru/view-php) - PHP templates
- [`codemonster-ru/view-ssr`](https://github.com/codemonster-ru/view-ssr) - SSR for Vue/React
- (future) Twig, Blade, and others
## Installation
```bash
composer require codemonster-ru/view
```
## Usage
```php
use Codemonster\View\View;
use Codemonster\View\Locator\DefaultLocator;
use Codemonster\View\Engines\PhpEngine; // package: codemonster-ru/view-php
$locator = new DefaultLocator([__DIR__ . '/resources/views']); // can be an array of paths
$engine = new PhpEngine($locator, 'php'); // default extension: php
$view = new View(['php' => $engine], 'php');
// Render template
echo $view->render('emails.welcome', ['user' => 'Vasya']);
// Looks for: resources/views/emails/welcome.php
// Access the locator of the default engine (added in v2.2.0)
$defaultLocator = $view->getLocator();
$defaultLocator->addPath(__DIR__ . '/vendor/package/views');
// Register namespaced view paths (added in v2.3.0)
$view->addNamespace('admin', __DIR__ . '/resources/views/admin');
echo $view->render('admin::dashboard', ['user' => 'Vasya']);
```
## Features
- Engine-agnostic core
- Support for multiple engines (`PhpEngine`, `SsrEngine`, `TwigEngine`, etc.)
- Unified `EngineInterface` interface
- Easy integration with frameworks (e.g., Annabel)
## Testing
You can run tests with the command:
```bash
composer test
```
## Author
[**Kirill Kolesnikov**](https://github.com/KolesnikovKirill)
## License
[MIT](https://github.com/codemonster-ru/view/blob/main/LICENSE)