entityManager = $entityManager; parent::__construct(); } protected function configure(): void { $this ->setDescription('Lists all users') ->setHelp('This command lists all users in the database.') ; } protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); //Get all users from database $users = $this->entityManager->getRepository(User::class)->findAll(); $io->info(sprintf("Found %d users in database.", count($users))); $io->title('Users:'); $table = new Table($output); $table->setHeaders(['ID', 'Username', 'Name', 'Email', 'Group']); foreach ($users as $user) { $table->addRow([ $user->getId(), $user->getUsername(), $user->getFullName(), $user->getEmail(), $user->getGroup() !== null ? $user->getGroup()->getName() . ' (ID: ' . $user->getGroup()->getID() . ')' : 'No group', ]); } $table->render(); return self::SUCCESS; } }