GeoDetect: PHP package for IP-based country detection
The ability to gather and analyze data about users' geographical locations has become increasingly vital for numerous applications. Whether it's personalizing content, tailoring marketing strategies, or implementing region-specific features, having accurate geolocation information can significantly enhance the user experience. To facilitate this process, GeoDetect package detects the country associated with an IP address.
GeoDetect is a framework-agnostic PHP package that allows to effortlessly extract valuable country information from IP addresses. Powered by a robust and up-to-date IP geolocation database, the package provides accurate results and ensures reliable performance. By Integrating GeoDetect into your PHP applications developers can easily implement geolocation functionality without the hassle of building and maintaining their own IP geolocation database.
Take a look on how to install Composer 2 on your computer to manage packages and its dependencies.
Assuming that Composer is already installed, you can include the package using Composer:
composer require hibit-dev/geodetect
Once installed, include the GeoDetect package in your class:
Instantiate the class or use dependency injection:
$geoDetect = new GeoDetect();
Retrieve country record providing user's IP address:
$country = $geoDetect->getCountry('XXX.XXX.XXX.XXX');
Finally, use available helpers to retrieve the required country information:
The package utilizes MaxMind's database in the background, which is regularly updated to ensure the accuracy of the data. However, you also have the option to use a self-hosted database by specifying the location of the DB file:
$country = $geoDetect->setCountriesDatabase('location_to_db_file')
GeoDetect is simple but yet powerful PHP package for IP-based country detection. Its seamless integration, accurate results, and efficient performance make it an invaluable tool for developers working on projects that require geolocation functionality. Whether you are building an e-commerce platform, a content management system, or an analytics dashboard, GeoDetect can enhance your application by providing essential country information based on IP addresses.
Official GitHub: https://github.com/hibit-dev/geodetect