Symfony - 仅在 dev 中定义路线.环境 [英] Symfony - Defining a route only in dev. environment

查看:17
本文介绍了Symfony - 仅在 dev 中定义路线.环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SF2,并创建了一些有助于调试项目的路线:

I'm using SF2 and I created some routes helping the debugging of the project:

widget_debug_page:
    path:       /debug/widget/{widgetName}
    defaults:   { _controller: WidgetBundle:Debug:default }

问题是这条路线在投入生产时必须永远不可到达.

The problem is that this route MUST never be reachable when going in production.

我找不到指定环境的参数.

I could not find a parameter to specify the environment.

推荐答案

只为希望与annotation系统一起使用的人:

Just for people who want use with annotation system:

/**
 * @Route("/my-route", condition="'dev' === '%kernel.environment%'")
 */
public function index() {}

这篇关于Symfony - 仅在 dev 中定义路线.环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆