spiral/views
Spiral Views provides a view manager and rendering engine selector for Spiral apps, letting you configure and switch template engines consistently. Lightweight, tested, and type-safe, with docs and framework integration via the Spiral Framework bundle.
Begin by installing the package via Composer and enabling the ViewsBootloader in your Spiral application’s bootloader stack (app/src/Application/Bootloader/AppBootloader.php). Configure view paths and engine adapters via config/views.php (or via environment variables). The first use case is typically rendering a simple template in a controller:
public function index(Factory $view): Response
{
return $view->render('home/index', ['title' => 'Welcome']);
}
Start by checking the src/View/FactoryInterface and default engine adapters (e.g., RawEngine, Plates, or Twig integrations) in config/views.php.
Spiral\View\FactoryInterface (or Spiral\View\RendererInterface) into controllers, services, or middleware for consistent rendering.namespace => path mapping in config to organize templates (e.g., admin::dashboard, shop::cart) and avoid path collisions.resources/views/layouts/main.phtml and extend them in child templates using {{ $layout->extend('layouts/main') }} or equivalent engine syntax.$view->render('components/header', $data) inside templates or controllers.Spiral\View\EngineInterface to plug in custom or newer template engines (e.g., Blade, Latte), then register them via config.'engines' => ['php' => PhpEngine::class]); mismatched names cause silent fallbacks or exceptions.render() calls match exactly.paths — use @var docblocks and debug with Factory::getTemplatePath($name) in dev.Factory into view templates themselves — pass data explicitly; circular dependencies can occur.Spiral\View\View to add global variables, global helpers, or custom render() decorators.spiral/blade if you need modern features (e.g., component slots, hot reloading).How can I help you explore Laravel packages today?