tattali / mobile-detect-bundle
Symfony 5.x-7.x 版本的移动设备检测、管理移动视图并跳转到移动和平板版面的套餐。
v2.3.1
2024-01-16 20:43 UTC
Requires
- php: >=8.2
- mobiledetect/mobiledetectlib: ^2.8.15
- symfony/dependency-injection: ^7.0
- symfony/event-dispatcher: ^7.0
- symfony/framework-bundle: ^7.0
- symfony/yaml: ^7.0
- twig/twig: ^2.0 || ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.0
- phpstan/phpstan-nette: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
- symfony/dotenv: ^7.0
- symfony/phpunit-bridge: ^7.0
This package is auto-updated.
Last update: 2024-09-16 22:34:45 UTC
README
MobileDetectBundle
Symfony 3.4.x-6.0.x 版本的移动设备检测、管理移动视图并跳转到移动和平板版面的套餐。
此套餐是 suncat2000/MobileDetectBundle 的分支。由于该项目似乎已不再维护,我们决定创建并维护一个分支。更多信息请参阅我们的 manifest。
简介
此套餐使用 Mobile_Detect 类,并提供以下功能
- 通过名称、操作系统、浏览器 User-Agent 检测各种移动设备
- 管理各种移动设备的网站视图(
mobile
、tablet
、full
) - 跳转到移动和平板网站
文档
安装
composer require tattali/mobile-detect-bundle
使用 Symfony 旧版本安装:这里
用法
检查设备
use MobileDetectBundle\DeviceDetector\MobileDetectorInterface; public function someaction(MobileDetectorInterface $mobileDetector) { $mobileDetector->isMobile(); $mobileDetector->isTablet(); $mobileDetector->is('iPhone'); }
使用 Twig
{% if is_mobile() %} {% if is_tablet() %} {% if is_device('iPhone') %} # magic methods is[...]
切换设备视图
要切换设备视图,请使用 device_view
GET 参数
http://localhost:8000?device_view={full/mobile/tablet}
深入了解
贡献和反馈
任何反馈和贡献都将非常受赞赏。
许可证和致谢
此套餐受 MIT 许可证保护。请参阅套餐中的完整 许可证。
原作者: suncat2000、HenriVesala、netmikey 以及 所有贡献者