vxm/yii2-mobile-first
Composer 安装命令:
composer require vxm/yii2-mobile-first
包简介
Support implementing mobile first principle for Yii2 application.
关键字:
README 文档
README
About it
An extension provide an easy way to implementing mobile-first principle base on Mobile Detect wrapper for Yii2 application.
Requirements
Installation
Require Yii2 Mobile First using Composer:
composer require vxm/yii2-mobile-first
Usage
This extension give you two features:
- Adaptive Filter support you redirect user to mobile site when detected user using mobile or tablet.
- View Render Behavior support you rendering view file by device type (mobile, tablet, iOs, android...).
Adaptive Filter
To use this filter you just add it to an application config file:
[
'id' => 'test',
'basePath' => __DIR__,
'vendorPath' => dirname(__DIR__) . '/vendor',
'components' => [
],
'as adaptiveFilter' => [
'class' => 'vxm\mobileFirst\AdaptiveFilter',
'redirectUrl' => ['https://m.yoursite.com', 'getParam1' => '1']
]
]
If user go to your site with url: yoursite.com/product?sort=price and you want to keep /product?sort=price url path
when redirect user to mobile site: m.yoursite.com/product?sort=price you just config:
[
'id' => 'test',
'basePath' => __DIR__,
'vendorPath' => dirname(__DIR__) . '/vendor',
'components' => [
],
'as adaptiveFilter' => [
'class' => 'vxm\mobileFirst\AdaptiveFilter',
'redirectUrl' => ['https://m.yoursite.com', 'getParam1' => '1'],
'keepUrlPath' => true
]
]
View Render Behavior
It is a way to replace a set of views with another by user device without the need of touching the original view rendering code.
You can use it to systematically change the look and feel of an application depend on user device.
For example, when call $this->render('about') in SiteController,
you will be rendering the view file @app/views/site/about.php, if user use mobile device,
the view file @app/views/site/mobile/about.php will be rendered, instead.
To use it, you need to attach it to the view application component in configure file:
[
'id' => 'test',
'basePath' => __DIR__,
'vendorPath' => dirname(__DIR__) . '/vendor',
'components' => [
'view' => [
'as mobileFirst' => [
'class' => 'vxm\mobileFirst\ViewRenderBehavior',
'dirMap' => [
'mobile' => 'mobile',
'tablet' => 'tablet'
]
]
]
]
]
The dirMap property governs how view files should be replaced by user device.
It takes an array of key-value pairs, where the keys are the device types and the values are the corresponding view sub-directory.
The replacement is based on user device: if user device match with any key in the dirMap array, a view path will be added with the corresponding sub-directory value.
Using the above configuration example, when user using mobile device because it match the key mobile, a view path will be added mobile look like @app/views/site/mobile/about.php.
Of course you can change the value or add more cases:
[
'id' => 'test',
'basePath' => __DIR__,
'vendorPath' => dirname(__DIR__) . '/vendor',
'components' => [
'view' => [
'as mobileFirst' => [
'class' => 'vxm\mobileFirst\ViewRenderBehavior',
'dirMap' => [
'mobile' => 'mobile-tablet',
'tablet' => 'mobile-tablet',
'ios' => 'ios',
'android' => 'android'
]
]
]
]
]
The above configuration if user using mobile or tablet device, the view path will be added mobile-tablet.
vxm/yii2-mobile-first 适用场景与选型建议
vxm/yii2-mobile-first 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 519 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 05 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「yii2」 「mobile-first」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vxm/yii2-mobile-first 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vxm/yii2-mobile-first 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vxm/yii2-mobile-first 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
OUDS Web is a Bootstrap based, Orange branded accessible and ergonomic components library.
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
The most advanced responsive front-end framework in the world.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
统计信息
- 总下载量: 519
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-05-01