Loading...
Loading...
Comprehensive skill for all Symfony framework components. Covers HTTP handling, dependency injection, forms, validation, caching, messaging, console commands, event dispatching, workflows, serialization, testing, filesystem operations, configuration, and utility components. Use when working with any Symfony component.
npx skill4agent add krzysztofsurdy/code-virtuoso symfonyfoo.bar[baz]# services.yaml — most services are autowired automatically
services:
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/'
exclude: '../src/{DI,Entity,Kernel.php}'use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class ArticleController
{
#[Route('/articles/{id}', methods: ['GET'])]
public function show(int $id): Response
{
return new Response("Article $id");
}
}use Symfony\Component\Messenger\MessageBusInterface;
class OrderService
{
public function __construct(private MessageBusInterface $bus) {}
public function place(Order $order): void
{
$this->bus->dispatch(new OrderPlaced($order->getId()));
}
}$form = $this->createForm(ArticleType::class, $article);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($form->getData());
$em->flush();
return $this->redirectToRoute('article_list');
}use Symfony\Contracts\Cache\ItemInterface;
$value = $cache->get('products_list', function (ItemInterface $item) {
$item->expiresAfter(3600);
$item->tag(['products']);
return $this->repository->findAll();
});
$cache->invalidateTags(['products']);use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(name: 'app:process', description: 'Process items')]
class ProcessCommand extends Command
{
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Processing...');
return Command::SUCCESS;
}
}use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class OrderSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [OrderPlacedEvent::class => 'onOrderPlaced'];
}
public function onOrderPlaced(OrderPlacedEvent $event): void
{
// Handle event
}
}if ($workflow->can($article, 'publish')) {
$workflow->apply($article, 'publish');
}$lock = $factory->createLock('pdf-generation', ttl: 30);
if ($lock->acquire()) {
try {
generatePdf();
} finally {
$lock->release();
}
}$cache->get()