thewunder / croute-bundle
There is no license information available for the latest version (dev-master) of this package.
Symfony Bundle for the Croute Router
dev-master
2024-11-08 17:48 UTC
Requires
- php: >=8.1
- symfony/config: ^6.1|^7.0
- symfony/dependency-injection: ^6.1|^7.0
- symfony/http-kernel: ^6.1|^7.0
- thewunder/croute: ^3.0
This package is auto-updated.
Last update: 2024-12-08 18:00:32 UTC
README
This package integrates the Croute Router into Symfony, and makes it available as a service.
Install using:
composer require thewunder/croute-bundle
Configure your controller namespace(s) in config/packages/croute.yaml
croute: namespaces: - App\Controller
In your Kernel.php return the CrouteKernel instead of the default symfony Router.
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; class Kernel extends BaseKernel { use MicroKernelTrait; public function getHttpKernel(): HttpKernelInterface { return $this->getContainer()->get('croute.kernel'); } }
And all controllers in the configured namespace(s) and set up for autowiring.
namespace App\Controller use Croute\Controller; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Response; class IndexController extends Controller { public function __construct(private readonly LoggerInterface $orm) { } public function indexAction(): Response { $this->logger->debug('IndexController->indexAction'); return new Response('Hello from Croute!'); } }