Fastpress View is a powerful and flexible templating engine for PHP, designed to render views and manage layouts seamlessly within the Fastpress framework.
Use Composer to install Fastpress View into your project:
composer require fastpress/view
You can create an instance of the View
class by passing the application context or configuration array.
$app = ['template' => ['views' => '/path/to/views/', 'layout' => '/path/to/layout/']];
$view = new \Fastpress\View\View($app);
Set configuration options using the set method:
$view->set('option', 'value');
Render a view file with optional variables:
$view->render('viewFile.php', ['variable' => 'value']);
Extend an existing layout file:
$view->extend('layoutFile');
Start and end content blocks within your layout:
$view->block('blockName');
// ... HTML and PHP content here ...
$view->endblock('blockName');
$view->content('blockName');
Set a layout file:
$view->layout('layoutFile');
Contributions are welcome! Please feel free to submit a pull request or open issues to improve the library.
This library is open-sourced software licensed under the MIT license.
If you encounter any issues or have questions, please file them in the issues section on GitHub.