Download the PHP package timefrontiers/php-location without Composer
On this page you can find all versions of the php package timefrontiers/php-location. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download timefrontiers/php-location
More information about timefrontiers/php-location
Files in timefrontiers/php-location
Package php-location
Short Description Get visitor's location information from IP address with multiple provider support
License MIT
Homepage https://github.com/timefrontiers/php-location
Informations about the package php-location
TimeFrontiers PHP Location
A modern, flexible PHP library to retrieve visitor location information from IP address with support for multiple GeoIP providers.
Features
- Multiple GeoIP provider support via interface – easily switch between services.
- Built-in free provider using ip-api.com (no API key required).
- Currency symbol mapping for over 100 currencies.
- Client IP auto-detection from common server headers.
- Error collection with access‑based filtering via
InstanceError. - Strict typing and modern PHP (8.1+).
- PSR‑4 autoloading.
Installation
Requirements
- PHP 8.1 or higher
- timefrontiers/php-instance-error ^1.0 (optional, for error display)
Basic Usage
Quick Start
Specify an IP Address
Refresh Location
Error Handling
Errors are stored in a protected $_errors property and can be retrieved with getErrors(). Use the InstanceError package to filter errors based on user rank.
GeoIP Providers
Default: ip-api.com (free)
The library uses ip-api.com by default with no API key required. Free tier limit: 45 requests per minute.
Using a Commercial ip-api.com Key
Creating a Custom Provider
Implement the GeoIPInterface and pass it to the constructor.
Currency Symbols
The library includes a static map of over 100 currency codes to symbols (CurrencySymbols::get('USD') // '$'). If a code is not found, the code itself is returned.
Available Properties
| Property | Type | Description |
|---|---|---|
$ip |
string | IP address used |
$city |
string | City name |
$city_code |
?string | Reserved for future use (currently null) |
$state |
string | Region/state name |
$state_code |
?string | Reserved for future use (currently null) |
$country |
string | Country name |
$country_code |
string | Two‑letter country code |
$currency_code |
string | Three‑letter currency code |
$currency_symbol |
string | Currency symbol (e.g. $, €, ₦) |
$latitude |
float | Latitude |
$longitude |
float | Longitude |
Security Considerations
- IP addresses are never stored locally; they are sent to the configured GeoIP provider.
- When using a free service, be aware of rate limits and privacy policies.
- Client IP detection respects proxy headers; ensure your application is configured securely.
License
MIT License. See LICENSE for details.