Symfony2 has a command for generating controllers
http://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_controller.html
Command’s default behavior is to generate the given controller inside controller
folder within the bundle.
Is it possible to customize the folder where the controller will be generated ( controller/backend
for example ) ?
Advertisement
Answer
You can get all the available options of this command with the help command:
JavaScript
x
php app/console help generate:controller
No you can’t with the current task, but you could extend the GenerateControllerCommand
to add custom options. Check out its generate
function:
JavaScript
// GenerateControllerCommand.php
public function generate(BundleInterface $bundle, $controller, $routeFormat, $templateFormat, array $actions = array())
{
$controllerFile = $dir.'/Controller/'.$controller.'Controller.php';
$this->renderFile('controller/Controller.php.twig', $controllerFile, $parameters);
}