Show a mobile-optimized layout when a visitor arrives on a phone or tablet.
Block or log requests from search engine crawlers instead of serving them normal pages.
Redirect users to a separate mobile subdomain based on their device type.
Log which browsers and operating systems your users are on to guide browser support decisions.
Agent is a PHP library that reads the user agent string sent by a visitor's browser and tells you what device, operating system, and browser they are using. When someone visits a website, their browser sends a short text string identifying itself. This string is called a user agent, and while it contains useful information, parsing it correctly requires handling a large variety of formats and edge cases. Agent wraps an existing library called Mobile Detect and extends it with additional detection capabilities for desktop browsers and more detailed device information. With Agent, a PHP application can ask questions like: is this visitor on a mobile phone, a tablet, or a desktop computer? Which browser are they using? What operating system? Is the request coming from a search engine crawler rather than a real person? Each of these checks returns a simple true or false, or a string with the name of the detected device or software. For example, you can call methods to get the browser name, the platform name, the device name, and the version numbers of each. The library integrates with the Laravel PHP framework through a service provider and a facade, which are the standard Laravel mechanisms for adding third-party packages. In a non-Laravel project it can also be used as a plain PHP class. Installation is handled through Composer, the standard PHP package manager. Agent is built on top of the Mobile Detect library, so all of Mobile Detect's detection methods are available in addition to the new ones Agent adds. Robot detection is handled by a separate library called Crawler Detect, which is included as a dependency. The library is licensed under the MIT license.
← jenssegers on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.