简体   繁体   English

Symfony项目中未检测到包的可能性?

[英]Possibility that a bundle is not detected in a Symfony project?

I work on Symfony 2.3 and I installed MobileDetectBundle that works on this symfony version: 我使用Symfony 2.3,并安装了可在此symfony版本上使用的MobileDetectBundle

I configured the bundle accordingly 我相应地配置了捆绑包

AppKernel.php AppKernel.php

new SunCat\MobileDetectBundle\MobileDetectBundle(),

config_mobile.yml config_mobile.yml

mobile_detect:
    redirect:
        full:
            is_enabled: true            # default false
            host: http://page.com       # with scheme (http|https), default null, url validate
            status_code: 301            # default 302
            action: redirect            # redirect, no_redirect, redirect_without_path
        mobile:
            is_enabled: true
            host: http://m.page.com
            status_code: 301
            action: redirect
        tablet:
            is_enabled: true
            host: http://t.page.com
            status_code: 301
            action: redirect
    switch_device_view:
        save_referer_path: true
    service:
        mobile_detector: mobile_detect.mobile_detector.default
    device_view_class: SunCat\MobileDetectBundle\Helper\DeviceView
    request_listener_class: SunCat\MobileDetectBundle\EventListener\RequestListener
    extension_class: SunCat\MobileDetectBundle\Twig\Extension\MobileDetectExtension

in my service.yml 在我的service.yml中

services:
    mobile_detector: @mobile_detect.mobile_detector.default

in app_mobile.php 在app_mobile.php中

$kernel = new AppKernel('mobile', false);

The bundle works with the mobiledetect classes. 该捆绑软件与mobiledetect类一起使用。 Both of them are present in my vendor, so I guess that the installation was done properly 他们两个都在我的供应商中,所以我想安装正确完成了

I restarted my server, PHP, cleared the cache but still it doesn't show me my redirection in the URL. 我重新启动了服务器PHP,清除了缓存,但仍然无法在URL中显示我的重定向。

Is it possible in some cases that Symfony doesn't recognize a bundle? 在某些情况下,Symfony是否可能无法识别捆绑包? Does that happens depending on the version you are? 这是否取决于您使用的版本?

Try this : 尝试这个 :

mobile_detect:
redirect:
    mobile: ~
    tablet: ~
switch_device_view: ~

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM