简体   繁体   中英

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:

I configured the bundle accordingly

AppKernel.php

new SunCat\MobileDetectBundle\MobileDetectBundle(),

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

services:
    mobile_detector: @mobile_detect.mobile_detector.default

in app_mobile.php

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

The bundle works with the mobiledetect classes. 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.

Is it possible in some cases that Symfony doesn't recognize a bundle? Does that happens depending on the version you are?

Try this :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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