- How do I install salmanzafar/laravel-geo-fence in Laravel?
- Install it with composer require salmanzafar/laravel-geo-fence. The package follows the standard Laravel package structure with a service provider, so package auto-discovery should register it without manual wiring in config/app.php. There are no migrations, credentials or external services to configure, so setup is a single command. Confirm the resolved version supports your Laravel and PHP versions before committing.
- Which Laravel and PHP versions does laravel-geo-fence support?
- The package describes itself as a Laravel 5 and 6 library, which means its Composer constraints for illuminate/support may be stale. Before installing, check the require block on Packagist or in composer.json to verify it allows your Laravel 10 or 11 and PHP 8.2+ versions. If the constraints block the install, use --ignore-platform-reqs only in a scratch branch to evaluate, not in production. A small single-maintainer package is a realistic candidate for outdated framework constraints.
- Does this package do true geofencing like point-in-polygon, or only distance between two coordinates?
- The published description only promises a distance calculation between two longitude/latitude pairs, while the name Geo-Fence implies boundary or point-in-polygon containment. The documentation does not clearly confirm true polygon geofencing, so do not assume it. If you need radius containment you can compute the distance and compare it to your radius, but true point-in-polygon checks likely require a package such as mjaschen/phpgeo. Verify the actual API in the source before designing around it.
- How do I calculate the distance between two latitude and longitude points in Laravel?
- Pass the latitude and longitude of both points to the package's distance method, typically through its facade or service class. The result is the great-circle distance computed with a Haversine-style formula in plain PHP. There is no database call, so you can use it anywhere in your application, including inside jobs, validators or Livewire components.
- What units does the distance calculation return, kilometres, miles or metres?
- Unit handling is not clearly documented in the package description, so check the source or configuration for whether results are kilometres, miles or metres and which earth radius constant is used. Mixing mean and equatorial radius, or assuming kilometres when the method returns miles, is a common source of wrong geofence decisions. Write a unit test against a known reference distance before relying on the output. If units are not configurable, wrap the call in your own converter.
- Can I use laravel-geo-fence to find stores or users within X km of a location?
- Yes, for modest result sets: load the candidate records, loop over them and compare each distance to your radius. This works well for delivery-radius checks or sorting a few dozen stores. For large tables or high-traffic search, compute and filter in the database with MySQL ST_Distance_Sphere plus a spatial index or PostGIS ST_DWithin instead of hydrating thousands of models.
- Is laravel-geo-fence safe to use in production and is it actively maintained?
- The package has very few stars and no dependents, and it is maintained by a single author, so there is essentially no production validation or ecosystem pressure to keep it current. Integration risk is low because it is a small, dependency-free utility, but provenance and longevity risk are moderate. Pin the version in composer.json and be prepared to replace it with a local helper. Review the repository's recent commit activity and open issues before adopting.
- How does laravel-geo-fence compare to mjaschen/phpgeo or a database spatial query?
- mjaschen/phpgeo is mature and widely used and covers distance, bearing and polygonal containment, so it is the better choice if you need real geofencing. Database-native options such as PostGIS ST_DWithin or MySQL ST_Distance_Sphere are the right tools when you need to filter or sort large datasets. A 30-line Haversine helper may be enough if you only ever need pairwise distance; that also removes the dependency entirely. Lock-in with this package is minimal, so switching later means changing one or two calls.
- Does laravel-geo-fence handle edge cases like the antimeridian, poles, invalid coordinates and float precision?
- Edge cases are not documented, so evaluate them yourself: antimeridian crossing near 180 degrees, high-latitude distortion, identical points returning zero, negative coordinates and null or invalid input. Float precision and the chosen earth radius also affect accuracy by small but measurable amounts. Add tests for these cases before trusting the package with access rules or delivery zones. If the package fails them, a maintained alternative or your own tested helper is preferable.
- How do I test geofence distance calculations in my Laravel app?
- Cover the calculation with a PHPUnit or Pest test that compares the package output to known-good reference values from PostGIS, phpgeo or a manually computed Haversine distance for a dozen coordinate pairs. Include identical points, negative coordinates, an antimeridian pair and a high-latitude pair. Run the package's own test suite locally if one exists. Treat any unexplained deviation in units or radius constant as a blocker before integrating into business rules.