jenssegers / agent Goto Github PK
View Code? Open in Web Editor NEW๐ฎ A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect
Home Page: https://jenssegers.com
License: MIT License
๐ฎ A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect
Home Page: https://jenssegers.com
License: MIT License
There's something wrong with ->platform()
, it returns WebKit
for Windows 10 users. I will check this weekend in fixing this.
There is no mention of adding 'Jenssegers\Agent\AgentServiceProvider'
to the providers section in /app/config/app.php
in the Installation-portion of the readme.md
Hi,
Do you have any plan on supporting L5 soon? :)
At this time, it throw this error : exception 'BadMethodCallException' with message 'Call to undefined method [package]'
Thanks :)
Hi.
I was trying to use your lib, but the method isMobile() was not available (the very same problem than this link: #20).
So, I used MobileDetect directly. I do not know what I did wrong, but MobileDirect worked fine.
Thank you.
When running composer update
from the terminal I get this error:
[Composer\DependencyResolver\SolverProblemsException]
Problem 1
- jeremeamia/SuperClosure 1.0.1 requires nikic/php-parser ~0.9 -> no matching package found.
- laravel/framework 4.1.x-dev requires jeremeamia/superclosure 1.0.* -> satisfiable by jeremeamia/SuperClosure[
1.0.1].
- Installation request for laravel/framework 4.1.* -> satisfiable by laravel/framework[4.1.x-dev].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
If I remove the Laravel-Agent-package it works fine.
Below is my specific composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Zizaco/ardent.git"
}
],
"require": {
"laravel/framework": "4.1.*",
"way/generators": "dev-master",
"schickling/backup": "dev-master",
"zizaco/entrust": "dev-master",
"intervention/image": "dev-master",
"mobiledetect/mobiledetectlib": "dev-master",
"jenssegers/agent": "*"
},
"require-dev": {
"jason-morton-nz/laravel-grunt": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/libraries",
"app/services"
]
},
"scripts": {
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-install-cmd": [
"php artisan optimize"
],
"post-update-cmd": [
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"github-oauth": {
"github.com": "secret"
}
},
"minimum-stability": "dev"
}
I was using Agent::agent() to return a full string of the user agent but that appears to have been removed now? If so why? Is there a better way of getting this?
Hello and good day,
I will be straightforward and I just want to report that your tool Sir cannot detect Chrome OS so far. Instead it returns 0.
Here is a sample user-agent for Chrome OS: 'Mozilla/5.0 (X11; CrOS x86_64 6680.78.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.102 Safari/537.36'.
Thanks a lot and may the Force be with you.
Hi,
I'm using this package and would have to detect console browsers. I found these:
For PS3:
Playstation 3 3.55
Mozilla/5.0 (PLAYSTATION 3; 3.55)
Playstation 3 2.00
Mozilla/5.0 (PLAYSTATION 3; 2.00)
Playstation 3 1.90
Mozilla/5.0 (PLAYSTATION 3; 1.90)
Playstation 3 1.70
Mozilla/5.0 (PLAYSTATION 3; 1.70)
Playstation 3 1.5
Mozilla/5.0 (PLAYSTATION 3; 1.5)
Playstation 3 1.10
Mozilla/5.0 (PLAYSTATION 3; 1.10)
Playstation 3 1.00
Mozilla/5.0 (PLAYSTATION 3; 1.00)
Mozilla/4.0 (PS3 (PlayStation 3); 1.00)
Mozilla/5.0 (PLAYSTATION 3; 1.0)
For XBOX 360 and XBOX ONE:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Xbox)
For the Wii & Wii U:
Mozilla/5.0 (Nintendo WiiU) AppleWebKit/536.28 (KHTML, like Gecko) NX/*** NintendoBrowser/***.US
I'd love to be able to do Agent::isConsole();
and thought I could pull request it but would ask you about it first. What do you think?
Thanks!
If i write {{Agent::browser()}}
and I open the page with Opera, I see writing "Opera" and when i open it with Opera Mini on mobile, i also see writing "Opera".
Opera and Opera Mini are very different, it's important to distinguish both. I don't really know how to do it but analytics systems like GA or Piwik do it properly.
Is there an other way to do it using jenssegers / agent ?
Nothing is correct on Windows Mobile: nor the version, nor the browser, nor the platform.
Here is the code:
use Jenssegers\Agent\Agent;
$agent = new Agent();
$txt = "";
$browser = $agent->browser();
$platform = $agent->platform();
$txt .= "Browser: ".$browser."<br>";
$txt .= "Version: ".$agent->version($browser)."<br>";
$txt .= "Platform: ".$platform."<br>";
$txt .= "Version: ".$agent->version($platform)."<br>";
$txt .= "Useragent: ".$_SERVER['HTTP_USER_AGENT']."<br>";
echo $txt;
and here the output
Browser: Safari
Version: 537
Platform: AndroidOS
Version: 4.0
Useragent: Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 730 Dual SIM) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537
this would be a nice extension of this very nice package, otherwise I have to combine and negate isMobile & isTablet which isn't that readable
Should be added to the package this new detections?
Agent::isPhablet();
Agent::isLaplet();
The mobile app built using QT hybrid application and we are not able to get it work using any of the following methods:
Agent::isMobile()
Agent::isTablet()
Agent::isAndroidOS()
The only method work is Agent::isDesktop() when sending the request using postman.
This is the current User-Agent value sent from the QT app : Mozilla/5.0
Any idea?
Do we have to setup the QT app to send some details about the user?
Thanks.
Hi, i am new to laravel and I wonder if there is any way I can use the Agent directly on my blade file so that according to him I can change the type of content I'll use (so is better than having to use browserhack )
sorry for my english, google help me =]
Why does the platform version not come as 7? for windows 7, it comes as platform: windows and platform_version: 6.1
config.php line 20
'windows phone' => 'Windows Phone' common missing
It could be great to have the browser's version ! ๐
Thanks for this very nice Laravel package. It doesn't seem to recognise IE11 as IE though.
Here's some notes I found on the subject..
http://blogs.msdn.com/b/ieinternals/archive/2013/09/21/internet-explorer-11-user-agent-string-ua-string-sniffing-compatibility-with-gecko-webkit.aspx
I think it can be solved by adding "Trident" to the regex:
'IE' => 'MSIE|IEMobile|MSIEMobile|Trident',
I am using v.2.3 in Laravel 5.2.
The GrapeShot crawler using the following user agent is not recognized as a bot:
Mozilla/5.0 (compatible; GrapeshotCrawler/2.0; http://www.grapeshot.co.uk/crawler.php)
It is incorrectly being returned as a desktop browser, and the device, browser, and other tests are all blank.
Screenshot of debug test results here:
https://www.evernote.com/l/AAMvzzMfUW1FOpu9pMk6n29vJqXYDWE0g3s
Example:
Mozilla/5.0 (iPhone; CPU iPhone OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12H321 [FBAN/FBIOS;FBAV/45.0.0.45.96;FBBV/18289579;FBDV/iPhone5,4;FBMD/iPhone;FBSN/iPhone OS;FBSV/8.4.1;FBSS/2; FBCR/VIVO;FBID/phone;FBLC/pt_BR;FBOP/5]
is returning Mozilla
on ->browser() method
Is it compatible with laravel 5.0 and laravel 5.3? I've tested with both and Facade is not working well.
Thanks
In isMobile method the matchDetectionRulrsAgainstUA function is triggered without the parameters, and in this case the function itself returns false
Is there a way to get a full user-agent ?
I'm using laravel 5.3 and failed to install because
php artisan asset:publish vendor/package
[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "asset" namespace.
Script php artisan asset:publish vendor/package handling the post-update-cmd event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
is there anyway I can install it on laravel 5.3?
I've run composer update to update my laravel 4.0.X version to fix the sessions problems.
But now, when I try to run composer update or any php artisan command, I always receive this message:
PHP Fatal error: Call to undefined method Illuminate\Foundation\Application::bindShared() in /var/www/myapp/vendor/jenssegers/agent/src/AgentServiceProvider.php on line 31
This line, 31 is the following:
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bindShared('agent', function($app)
{
return new Agent;
});
}
Do you know how can I fix it?? It is really important
Thanks
I'm using Laravel 4.1 and the latest version of Laravel-Agent (says 4.* in composer.json) and when I try:
var_dump(Agent::platform())
it says
string(3) "iOS"
And also Agent::isMobile() says true.
Any ideas on this?
I could use this method and it's very easy to implement since its just something like !isMobile && !isTablet
Would be nice if you could support Vivaldi (https://vivaldi.com/).
Here is the current data (same code as in #58)
Browser: Chrome
Version: 51.0.2704.103
Platform: Windows
Version: 10.0
Useragent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 Vivaldi/1.2.490.43
expected data:
Browser: Vivaldi
Version: 1.2.490.43
Platform: Windows
Version: 10.0
Although it's a bit taboo right now - this is of course broken on L5.
Easy to fix though. Remove the boot method from your provider. It's not needed. The package does not require any config or anything.
I have a fork and did just that and have been using it happily for probably a month.
Cheers!
Hello, I am new in using this library and somehow, it is good.
But in my testing, I discovered that it cannot detect Opera. It otherwise returned Google Chrome. When I looked in my database, the agent returned "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36 OPR/27.0.1689.76" and I guessed that the library reads the "Chrome" string and not the OPR. Please fix this issue.
Thanks.
Hi,
Seems Mobile Safari 4 is getting parsed as Safari 4.0. any way to check this out?
Under what circumstances all agent data might be unavailable if it's not a robot?
I'm logging requests in my app and I'm getting a bunch of entries like that.
Hi,
i setup this configuration
use Jenssegers\Agent\Agent;
$agent = new Agent();
if($agent->isMobile()){
$realpath = "resources/mobile";
}
else{
$realpath = "resources/desktop";
}
however, when i visit the application from an IPAD, i see the mobile version.
Thanks!
With Laravel 5 and Jenssegers installed you get this error:
Call to undefined method Jenssegers\Agent\Facades\Agent::platform()
Request code:
$agent = new \Agent;
return $agent->platform();
If I call it statically it returns false.
return \Agent::browser($request->header('user-agent'));
Note: this is a clean install with the latest Lavarvel 5.2.x and jenssegers/agent (v2.3.3)
Should I replace the (outdated?) CodeIgniter code with: https://github.com/serbanghita/Mobile-Detect ?
What do you guys think.
It would be nice to have a isPhone check. sure would look nicer than:
(Agent::isMobile() && !Agent::isTablet())
Thanks!
For every method I try to use with the Facade class I get the following error:
Call to undefined method Jenssegers\Agent\Facades\Agent::isMobile() (or similar )
Can anyone tell me how to solve this? I did include the Facade and the ServiceProvider in my app/config/app.php
Apologies if this is a known issue
UA string "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98 )"
Yields a browser name/version and os name/version of "0" (ZERO)
It doesn't occur too often, but I have about 300 page views on browser "0" for every 25,000 page views.
Agent::isRobot() no return true if i share on g+ .
The UA info is :
Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110814 Firefox/6.0 Google (+https://developers.google.com/+/web/snippet/)
Hi,
What about this: http://stackoverflow.com/questions/6322112/check-if-php-page-is-accessed-from-an-ios-device ?
Bests
in Mobile_Detect.php on line 524:
protected static $utilities = array(
// Experimental. When a mobile device wants to switch to 'Desktop Mode'.
// http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
// https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
// https://developers.facebook.com/docs/sharing/best-practices
'Bot' => 'YandexBot|YandexImages|YandexVideo|YandexMedia|YandexBlogs|YandexFavicons|YandexWebmaster|YandexPagechecker|YandexImageResizer|YandexDirect|YaDirectFetcher|YandexCalendar|YandexSitelinks|YandexAdNet|YandexMetrika|YandexNews|YandexNewslinks|YandexCatalog|YandexAntivirus|YandexMarket|YandexVertis|YandexForDomain|YandexBot|Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor',
'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
'DesktopMode' => 'WPDesktop',
'TV' => 'SonyDTV|HbbTV', // experimental
'WebKit' => '(webkit)[ /]([\w.]+)',
// @todo: Include JXD consoles.
'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
'Watch' => 'SM-V700',
);
it's only Yandex bots added
YandexBot|YandexImages|YandexVideo|YandexMedia|YandexBlogs|YandexFavicons|YandexWebmaster|YandexPagechecker|YandexImageResizer|YandexDirect|YaDirectFetcher|YandexCalendar|YandexSitelinks|YandexAdNet|YandexMetrika|YandexNews|YandexNewslinks|YandexCatalog|YandexAntivirus|YandexMarket|YandexVertis|YandexForDomain|YandexBot
Hello.
When I call isMobile()
on an iPad it returns true. Should this be the case?
I am using isMobile()
and isTablet()
to find out if the user is visiting my site with a mobile (eg: iPhone), tablet (eg: iPad) or PC, so I can serve different content, based on each device.
Why isn't iPad recognized as Tablet?
Thank you,
Ilias
Great library. We're using it in production. Have you considered extending the list of robots to include more possibilities? I would think any user agent string with the term 'bot' in it would do the trick.
Will Microsoft Edge browser support be added soon?
I installed using composer as in the description.
I tried composer dumpautoload, I reinstalled the package and still the same error.
I'm doing something wrong?
Mention: I use laravel 5.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.