From f650b62adddde1707c29ee2a381e222e082d2a09 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 8 Sep 2025 17:25:09 +0200 Subject: [PATCH] [Demo] Convert blog commands to invokable commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert EmbedCommand and QueryCommand to use Symfony 7.3's invokable commands pattern: - Remove Command class inheritance - Use __invoke(SymfonyStyle $io) signature instead of execute() method - Simplify parameter handling by accepting SymfonyStyle directly 🤖 Generated with [Claude Code](https://claude.ai/code) --- demo/src/Blog/Command/EmbedCommand.php | 8 ++------ demo/src/Blog/Command/QueryCommand.php | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/demo/src/Blog/Command/EmbedCommand.php b/demo/src/Blog/Command/EmbedCommand.php index 370a25f34..a97ec064e 100644 --- a/demo/src/Blog/Command/EmbedCommand.php +++ b/demo/src/Blog/Command/EmbedCommand.php @@ -14,22 +14,18 @@ use App\Blog\Embedder; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand('app:blog:embed', description: 'Create embeddings for Symfony blog and push to ChromaDB.')] -final class EmbedCommand extends Command +final class EmbedCommand { public function __construct( private readonly Embedder $embedder, ) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(SymfonyStyle $io): int { - $io = new SymfonyStyle($input, $output); $io->title('Loading RSS of Symfony blog as embeddings into ChromaDB'); $this->embedder->embedBlog(); diff --git a/demo/src/Blog/Command/QueryCommand.php b/demo/src/Blog/Command/QueryCommand.php index a8858f589..3128c7238 100644 --- a/demo/src/Blog/Command/QueryCommand.php +++ b/demo/src/Blog/Command/QueryCommand.php @@ -16,23 +16,19 @@ use Symfony\AI\Platform\PlatformInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand('app:blog:query', description: 'Test command for querying the blog collection in Chroma DB.')] -final class QueryCommand extends Command +final class QueryCommand { public function __construct( private readonly Client $chromaClient, private readonly PlatformInterface $platform, ) { - parent::__construct(); } - protected function execute(InputInterface $input, OutputInterface $output): int + public function __invoke(SymfonyStyle $io): int { - $io = new SymfonyStyle($input, $output); $io->title('Testing Chroma DB Connection'); $io->comment('Connecting to Chroma DB ...');