Download the PHP package kodhe/agent without Composer
On this page you can find all versions of the php package kodhe/agent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Vendor kodhe
Package agent
Short Description Kodhe User Agent detection library - PSR-4 compatible with CodeIgniter 3 support
License MIT
Package agent
Short Description Kodhe User Agent detection library - PSR-4 compatible with CodeIgniter 3 support
License MIT
Please rate this library. Is it a good library?
Informations about the package agent
Kodhe Agent Library
A modern, modular, PSR-4 compatible User Agent detection library with full backward compatibility for CodeIgniter 3.
Features
- PSR-4 Autoloading: Modern namespace-based autoloading
- PSR-12 Coding Style: Follows PHP-FIG coding standards
- Modular Architecture: Separated into drivers, parsers, and collections
- Dependency Injection: Easy to test and extend
- CodeIgniter 3 Compatible: 100% backward compatible with CI3 API
- Unit Testable: Built with testing in mind
Installation
Via Composer
Manual Installation
- Clone or download the repository
- Copy the
srcfolder to your project - Include the autoloader:
Usage
CodeIgniter 3 Style (Backward Compatible)
Modern PSR-4 Style
Custom User Agent Parsing
Architecture
Design Patterns Used
- Strategy Pattern: Each driver implements detection strategy
- Factory Pattern: Drivers are created through dependency injection
- Dependency Injection: All dependencies injected via constructor
- Interface Segregation: Separate interfaces for different responsibilities
- Single Responsibility: Each class has one job
Configuration
Create application/config/agent.php:
Load configuration:
Running Tests
API Reference
Main Methods (CI3 Compatible)
| Method | Description | Returns |
|---|---|---|
browser() |
Get browser name | string |
version() |
Get browser version | string |
platform() |
Get OS/Platform | string |
mobile() |
Get mobile device | string |
robot() |
Get robot name | string |
is_browser($key) |
Check if browser | bool |
is_mobile($key) |
Check if mobile | bool |
is_robot($key) |
Check if robot | bool |
is_referral() |
Check if referral | bool |
agent_string() |
Get full UA string | string |
languages() |
Get accepted languages | array |
charsets() |
Get accepted charsets | array |
accept_lang($lang) |
Check language | bool |
accept_charset($charset) |
Check charset | bool |
referrer() |
Get referrer URL | string |
parse($string) |
Parse custom UA | void |
Modern Methods (PSR-4)
| Method | Description | Returns |
|---|---|---|
isBrowser($key) |
Check if browser | bool |
isMobile($key) |
Check if mobile | bool |
isRobot($key) |
Check if robot | bool |
isDesktop() |
Check if desktop | bool |
isReferral() |
Check if referral | bool |
agentString() |
Get full UA string | string |
acceptLang($lang) |
Check language | bool |
acceptCharset($charset) |
Check charset | bool |
Driver Access Methods
Extending the Library
Custom Browser Collection
Custom Driver
Requirements
- PHP 8.1+
- For CodeIgniter 3: CodeIgniter 3.x
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create your feature branch
- Run tests:
vendor/bin/phpunit - Submit a pull request
Changelog
Version 2.0.0
- Complete refactor to PSR-4 structure
- Added modular drivers architecture
- Full CodeIgniter 3 backward compatibility
- Added comprehensive unit tests
- PSR-12 coding standards compliance
Version 1.1.0
- Initial release
All versions of agent with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
The package kodhe/agent contains the following files
Loading the files please wait ...