lsxiao / user-agent-for-laravel5
a UserAgent parser package for laravel5 which is based on WhichBrowser/Parser
This package's canonical repository appears to be gone and the package has been frozen as a result.
1.0.0
2016-04-29 14:48 UTC
Requires
- php: >=5.5.9
- whichbrowser/parser: ^2.0
This package is not auto-updated.
Last update: 2022-04-02 05:12:10 UTC
README
a UserAgent parser package for laravel5 which is based on WhichBrowser/Parser
Install
PHP >= 5.5.9
install package
- use composer
composer require "lsxiao/user-agent-for-laravel5"
Configure
Laravel
- register ServiceProvider in config/app.php
Lsxiao\UserAgent\UserAgentServiceProvider::class
- add alias to aliases array in config/app.php
'UA' => Lsxiao\UserAgent\Facades\UserAgent::class
Usage
basic usage
the UserAgent is a child instance of WhichBrowser/Parser class,but added some methods.
<?php // the added functions. UA::isCellphone(); UA::isRobot(); UA::isTablet(); UA::isGaming(); UA::isEreader(); UA::isMedia(); UA::isEmulator(); UA::isTV(); UA::isMonitor(); UA::isCamera(); UA::isSignage(); UA::isCar(); UA::isPos(); UA::parse(); UA::parse($headers,$option=[]);//this method will return the UserAgent instance. // you can use it like this UA::parse($headers,$option)->isRobot(); UA::parse($headers,$option)->toString(); //QQ Browser 3.9 UA::parse($headers,$option)->browser->toString(); // Chrome 50 UA::parse($headers,$option)->engine->toString(); // Webkit UA::parse($headers,$option)->os->toString(); // OS X El Caption 10.11.4
more usage to see WhichBrowser/Parser
License
MIT