Skip to content

Commit 31c6606

Browse files
committed
added a warning when no routes are defined
1 parent afcb4be commit 31c6606

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Command/MakeControllerCommand.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313

1414
use Symfony\Bundle\MakerBundle\ConsoleStyle;
1515
use Symfony\Bundle\MakerBundle\DependencyBuilder;
16+
use Symfony\Bundle\MakerBundle\Generator;
1617
use Symfony\Bundle\MakerBundle\Str;
1718
use Symfony\Bundle\MakerBundle\Validator;
1819
use Symfony\Component\Console\Input\InputArgument;
1920
use Symfony\Component\Console\Input\InputInterface;
2021
use Symfony\Component\Console\Output\OutputInterface;
22+
use Symfony\Component\Routing\RouterInterface;
2123
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
2224

2325
/**
@@ -28,6 +30,15 @@ final class MakeControllerCommand extends AbstractCommand
2830
{
2931
protected static $defaultName = 'make:controller';
3032

33+
private $router;
34+
35+
public function __construct(Generator $generator, RouterInterface $router)
36+
{
37+
$this->router = $router;
38+
39+
parent::__construct($generator);
40+
}
41+
3142
public function configure()
3243
{
3344
$this
@@ -63,6 +74,11 @@ protected function getResultMessage(array $params): string
6374

6475
protected function writeNextStepsMessage(array $params, ConsoleStyle $io)
6576
{
77+
if (!count($this->router->getRouteCollection())) {
78+
$io->text('<error> Warning! </> No routes configuration defined yet.');
79+
$io->text(' You should probably uncomment the annotation routes in <comment>config/routes.yaml</>');
80+
$io->newLine();
81+
}
6682
$io->text('Next: Open your new controller class and add some pages!');
6783
}
6884

0 commit comments

Comments
 (0)