承接 yan/device-detector-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yan/device-detector-bundle

最新稳定版本:v1.0.2

Composer 安装命令:

composer require yan/device-detector-bundle

包简介

Symfony2 bundle for detecting devices and directing them to correct controllers.

README 文档

README

Symfony2 Bundle for switching controllers for different device views. This caters to adaptive websites with two different controller for mobile and desktop views.

Sample Configuration

1. Simple desktop to mobile controller redirect.

This will render th mobile view for tablets as well.

device_detector:
    mobile:
        enabled: true
        controllers:
            -
                from_controller_path: 'Acme\MainBundle\Controller\Frontend'
                to_controller_path: 'Acme\MainBundle\Controller\MobileFrontend'
                routes:
                    - 'acme_frontend_homepage'
                    - 'acme_frontend_news'
                    - 'acme_frontend_about_us'

2. Simple desktop to mobile redirection but render desktop view for tablets.

device_detector:
    tablet:
        treat_as_mobile: false
        controllers: []
    mobile:
        enabled: true
        controllers:
            -
                from_controller_path: 'Acme\MainBundle\Controller\Frontend'
                to_controller_path: 'Acme\MainBundle\Controller\MobileFrontend'
                routes:
                    - 'acme_frontend_homepage'
                    - 'acme_frontend_news'
                    - 'acme_frontend_about_us'

3. Simple desktop to tablet controller redirect.

By default, the bundle will treat tablets as mobile devices and will follow the configuration for mobile redirection, so it is important to set treat_as_mobile to false when tablet redirection is enabled.

device_detector:
    tablet:
        enabled: true
        treat_as_mobile: false
        controllers:
            -
                from_controller_path: 'Acme\MainBundle\Controller\Frontend'
                to_controller_path: 'Acme\MainBundle\Controller\TabletFrontend'
                routes:
                    - 'acme_frontend_homepage'
                    - 'acme_frontend_news'
                    - 'acme_frontend_about_us'
    mobile:
        enabled: true
        controllers:
            -
                from_controller_path: 'Acme\MainBundle\Controller\Frontend'
                to_controller_path: 'Acme\MainBundle\Controller\MobileFrontend'
                routes:
                    - 'acme_frontend_homepage'
                    - 'acme_frontend_news'
                    - 'acme_frontend_about_us'

4. Setting optional mobile view.

An option is provided for optional rendering of mobile pages via setting of a cookie. If this cookie is set, this will override the redirection and render the desktop version until cookie expires.

device_detector:
    override_cookie: 'DEVICE_DETECTOR_OVERRIDE'
    tablet:
        enabled: true
        treat_as_mobile: false
        controllers:
            -
                from_controller_path: 'Acme\MainBundle\Controller\Frontend'
                to_controller_path: 'Acme\MainBundle\Controller\TabletFrontend'
                routes:
                    - 'acme_frontend_homepage'
                    - 'acme_frontend_news'
                    - 'acme_frontend_about_us'
    mobile:
        enabled: true
        controllers:
            -
                from_controller_path: 'Acme\MainBundle\Controller\Frontend'
                to_controller_path: 'Acme\MainBundle\Controller\MobileFrontend'
                routes:
                    - 'acme_frontend_homepage'
                    - 'acme_frontend_news'
                    - 'acme_frontend_about_us'

统计信息

  • 总下载量: 123
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-01