【问题标题】:List all routes with the settings in Symfony 2列出所有在 Symfony 2 中设置的路由
【发布时间】:2016-03-29 15:05:46
【问题描述】:

我想知道是否有办法列出我的应用程序中的所有路由。我的应用程序正在使用 symfony 2.1

订单路由器:

  • debug 只显示带有可选参数值的路由。 例如。

    app_product_distributors ANY / local _ {} / {} choose_distributor /

我希望路由具有可能的参数值,以避免在我的 routing.yml 中列出所有控制器等

例如

app_product_distributors ANY / local _ {} / {} choose_distributor / _locale with: en | fr _choose_distributor: choose_distributor | choisir_fournisseur

谁能帮帮我?

谢谢

【问题讨论】:

  • 你能把你的问题翻译成英文吗?
  • Presque tout les personnes utilisant stack overflow seulement sait parler anglais, pas de français。 Comme ça, la langue préféré est anglais。
  • 哈哈感谢谷歌翻译:P
  • @Randrian 不要说英语是最喜欢的语言,(即使它适合你),只要说那是官方语言...外交并不昂贵...跨度>
  • 我不确定它本身是否可行。也许,我错了...如果您已经以 yaml 格式定义了路由,您应该能够在控制台命令中解析配置文件...

标签: php symfony


【解决方案1】:

这是一个在控制台中显示routing.yml 的非常基本的命令。

  1. 考虑routing.yml路径=app/config/routing.yml
  2. src/AppBundle/Command/ 中创建DumpRoutingCommand.php

...

namespace AppBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DumpRoutingCommand extends Command
{
     protected function configure()
     {
        $this
            ->setName('routing:dump')
            ->setDescription('Displays routing.yml in console')
        ;
     }

     protected function execute(InputInterface $input, OutputInterface $output)
     {
        $output->writeln(file_get_contents(__DIR__ . '/../../../app/config/routing.yml'));
     }
}

然后,启动php app/console routing:dump

希望对你有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多