CakePHP 插件,提供对请求您网站的客户端应用程序信息的轻松访问
v1.0.1
2017-05-16 14:56 UTC
Requires
- php: >=5.6
- sinergi/browser-detector: ^6.1
Requires (Dev)
- cakephp/cakephp: ^3.2
- cakephp/cakephp-codesniffer: ^3.0
- phpunit/phpunit: ^6.1
This package is not auto-updated.
Last update: 2024-09-29 02:23:53 UTC
README
CakePHP ClientInfo 插件
此插件提供对请求您网站的客户端应用程序信息的轻松访问。它只是一个包装器,并使用 浏览器检测库 来收集数据。
要求
- PHP >= 5.6
- CakePHP >= 3.0
如何安装
composer require okatsuralau/cakephp-clientinfo@1.0.0
如何使用
在您的 config/bootstrap.php 文件中加载插件
Plugin::load('CakephpClientInfo');
在您的 src/Controller/AppController.php 中加载组件
public function initialize() { parent::initialize(); $this->loadComponent('CakephpClientInfo.ClientInfo'); }
要获取客户端信息,请使用
public function index() { // returns the browser name (eg.: Chrome) $this->ClientInfo->browser(); // returns the O.S. name (eg.: Linux) $this->ClientInfo->os(); // returns the Device name (eg.: Computer, Mobile, Tablet, iPhone, ...) $this->ClientInfo->device(); // returns the browser's language (eg.: en) $this->ClientInfo->language(); // or you can access the original instance and make calls directly to the browser-detector $this->ClientInfo->Browser()->getName(); }
有关 浏览器检测库 的更多信息。
许可证
版权所有 2017 Gabriel Lau
在 MIT 许可下可供您使用。查看:https://open-source.org.cn/licenses/MIT