Revision: Tue, 29 Oct 2024 10:57:17 GMT
v1.0 – outdated
This version of the documentation is outdated. Consider upgrading your project to Spiral Framework 3.14
Edit this page

Native Views

You can use plain php files as your views without any compilation or cache layer.

Accessing Container inside view

You can access Spiral\Views\Engines\Native\NativeView instance inside your template.

php
Hello world, <?= $name ?>!

<?php dump($this->container->get(MyService::class)); ?>

NativeView declares IoC scope for static container, you can use app or spiral:

php
Hello world, <?= $name ?>!

<?= spiral(MyService::class)->someMethod(); ?>
<?= spiral('faker')->someMethod(); ?>
<?= app()->faker->name ?>