FOSJs路由捆绑包

FOSJsRouting Bundle

本文关键字:路由 FOSJs      更新时间:2023-09-26

我的 Js 路由配置中出错。我在控制台日志中收到"未捕获错误:路由"pspiess_letsplay_customer_new"不存在"。我已经通过作曲家安装了捆绑包。我已经完成了所有 4 项。步骤

我的symfony版本2.3.21

我的应用内核

        $bundles = array(
        //.....
        new pspiess'LetsplayBundle'pspiessLetsplayBundle(),
        new Knp'Bundle'MenuBundle'KnpMenuBundle(),
        new Braincrafted'Bundle'BootstrapBundle'BraincraftedBootstrapBundle(),
        new JMS'SerializerBundle'JMSSerializerBundle(),
        new FOS'JsRoutingBundle'FOSJsRoutingBundle(),
        //.....
    );

我的路由.yml

fos_js_routing: 资源:"@FOSJsRoutingBundle/资源/配置/路由/路由.xml"

pspiess_letsplay: 资源:"@pspiessLetsplayBundle/控制器/" 资源:"@pspiessLetsplayBundle/资源/配置/路由.yml" 前缀:/

我的路线

pspiess_letsplay_customer_new:
pattern:  /admin/customer/new
defaults: { _controller: pspiessLetsplayBundle:Customer:new }

我的操作

    /**
 * Displays a form to create a new Customer entity.
 *
 * @Route("/new", name="customer_new")
 * @Method("GET")
 * @Template()
 */
public function newAction() {
    $entity = new Customer();
    $form = $this->createCreateForm($entity);
    return array(
        'entity' => $entity,
        'form' => $form->createView(),
    );
}

我的 Js 代码

click: function() {
  console.log(Routing.generate('pspiess_letsplay_customer_new'));

}

我的"路由器:调试" - 使用我的路由找到的所有路由pspiess_letsplay_booking_new任何任何/管理员/预订/新

我的"fos:js-routeting:debug" - 找不到路由

我认为我的路由配置有问题,但我不知道是什么。

感谢您的帮助。

你不是在路由中缺少暴露选项吗?

pspiess_letsplay_customer_new:
pattern:  /admin/customer/new
defaults: { _controller: pspiessLetsplayBundle:Customer:new }
options:
    expose: true