UX 2022 recipes:update 2018 Silex symfony/symfony Symfony DX in 5 key dates Each new version brings DX improvements "New in Symfony X.Y" posts / tag on Github Since 2014 DX 🤝
#[Route('/hello/{name}', defaults: ['name' => 'World'])] public function hello(string $name): Response { return new Response('Hello '.$name); } Multi-controllers in the same file Any method name Hello
function wow(): Response { return new Response('wow'); } #[Route('/{name}', defaults: ['name' => 'World'])] public function hello(string $name): Response { return new Response('Hello '.$name); } } Mount routes Hello
$context['APP_DEBUG'], $context); return new AppKernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); }; With auto-navigation in the browser Hello
as BaseKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; class Kernel extends BaseKernel { use MicroKernelTrait; private function configureRoutes(RoutingConfigurator $routes): void { $routes->import(dirname(__DIR__).'/src/*Controller.php', 'attribute'); } } src/Kernel.php
use Symfony\Component\Routing\Attribute\Route; #[AsController] class HelloController { #[Route('/hello')] public function hello(): Response { return new Response('Hello'); } } src/HelloController.php No base class
Examples / Demo Small to medium Individual Self-defined Self-defined Personal projects Single-purpose apps Quick proof of concepts Medium to large Team Standardized Documented Team collaboration Long-term maintenance Complex business logic Scale Developers Structure Conventions Best for
to define and inject arguments directly. Use it. More documentation here: @https://github.com/symfony/symfony/pull/59340 Looking at the pull request, Symfony 7.3 introduces some exciting DX improvements for console commands, particularly the ability to use invokable commands with attribute-based arguments. Let's update your ColorSchemeCommand to use these new features: - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(SymfonyStyle $io, #[Argument(description: 'Hex color (e.g. #FFFFFF)')] string $color): int Human LLM