Skip to content

Commit

Permalink
Add TemplateController to Spiral example application (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored Nov 8, 2022
1 parent 9c2cfb8 commit ac5c214
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 48 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace App\Api\Web\Controller;

use Schranz\Templating\TemplateRenderer\TemplateRendererInterface;
use Spiral\Router\Annotation\Route;

class TemplateController
{
public function __construct(
private ?TemplateRendererInterface $defaultRenderer
) {
}

#[Route(route: '/', name: 'index', methods: 'GET')]
public function index(): string
{
return
'<h1>Goto /</h1>' .
'<p>Default Renderer is: ' . get_debug_type($this->defaultRenderer) . '</p>'
;
}
}
3 changes: 1 addition & 2 deletions examples/usages/spiral/app/src/Api/Web/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use App\Api\Web\Controller\HomeController;
use Spiral\Router\Loader\Configurator\RoutingConfigurator;

/*
Expand All @@ -16,5 +15,5 @@
* @link https://spiral.dev/docs/keeper-routing/#register-routes-via-annotations
*/
return static function (RoutingConfigurator $routes): void {
$routes->add('home', '/<action>')->controller(HomeController::class);
// routes used via attributes
};
2 changes: 2 additions & 0 deletions examples/usages/spiral/app/src/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Spiral\Nyholm\Bootloader as Nyholm;
use Spiral\Prototype\Bootloader as Prototype;
use Spiral\RoadRunnerBridge\Bootloader as RoadRunnerBridge;
use Spiral\Router\Bootloader\AnnotatedRoutesBootloader;
use Spiral\Sapi\Bootloader\SapiBootloader;
use Spiral\Scaffolder\Bootloader as Scaffolder;
use Spiral\Stempler\Bootloader as Stempler;
Expand Down Expand Up @@ -66,6 +67,7 @@ class Kernel extends \Spiral\Framework\Kernel
Framework\Http\CsrfBootloader::class,
Framework\Http\PaginationBootloader::class,
SapiBootloader::class,
AnnotatedRoutesBootloader::class,

// Databases
CycleBridge\DatabaseBootloader::class,
Expand Down

0 comments on commit ac5c214

Please sign in to comment.