Revision: Thu, 18 Apr 2024 09:24:10 GMT
v1.0 – outdated
This version of the documentation is outdated. Consider upgrading your project to Spiral Framework 3.12
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 ?>