devrabiul/laravel-geo-genius
Laravel GeoGenius adds IP geolocation, automatic timezone detection/conversion, locale & translation helpers, number conversion, and a country picker with phone formatting/validation. Works with Livewire and supports cookies or headers for detection.
GeoLocationService, TimezoneService, LanguageService), allowing selective adoption of features (e.g., only using geolocation or phone validation).GeoDataUpdated) for custom logic.geo:add-timezone-column).intl-tel-input, which is auto-injected.ipwho.is, ip-api.com) but abstracts this away with caching and fallback mechanisms. This reduces vendor lock-in risk.laravelGeoGenius()) are accessible anywhere in the application.intl-tel-input) and manual validation logic in the frontend. This adds complexity for teams not already using this library.timezone column to tables, but this is optional. Retrofitting timezone support to existing databases may require downtime or careful planning.intl-tel-input for phone validation, or would a custom solution be preferable?GeoLocationService, TimezoneService) could be adapted for APIs by:
X-Forwarded-For) instead of session.timezone column to the users table via migration.public function handle(Request $request, Closure $next) {
$request->merge(['geo_data' => laravelGeoGenius()->geo()->locateVisitor()]);
return $next($request);
}
timezone column is simple and works with most databases (MySQL, PostgreSQL, SQLite). No schema changes are required for other features.composer require devrabiul/laravel-geo-genius
php artisan vendor:publish --provider="Devrabiul\LaravelGeoGenius\LaravelGeoGeniusServiceProvider"
php artisan migrate
config/laravel-geo-genius.php (e.g., default timezone, locales, phone input settings).geo:add-timezone-column migration to your user table (or other relevant tables).$timezone = laravelGeoGenius()->geo()->getTimezone();
php artisan geo:add-language en
php artisan geo:add-language bn
{!! laravelGeoGenius()->initIntlPhoneInput() !!}
<input id="phone" type="tel" name="phone">
$this->rules([
'phone' => 'required|phone:US', // Adjust country code as needed
]);
laravelGeoGenius() helper is called within the component’s lifecycle (e.g., mount() or updated()) to refresh data as needed.geo:translations-generate, geo:translate-language) automate this but require initial setup.How can I help you explore Laravel packages today?