- What is spinen/laravel-geometry used for?
- spinen/laravel-geometry is a thin Laravel and Eloquent wrapper over geoPHP. It provides casts and helpers so spatial database values such as points, lines, and polygons can be hydrated into geoPHP geometry objects and serialized back. It is intended for basic storage and retrieval of geometry in Laravel apps, not full GIS analytics.
- How do I install spinen/laravel-geometry in a Laravel app?
- Install it with Composer using the package name spinen/laravel-geometry, then configure your Eloquent models to use its geometry casts. You also need spatial-capable database columns and the appropriate database extension or spatial support. Pin the package and geoPHP versions and verify the exact Laravel, PHP, and database matrix in CI because upstream releases are old.
- Which Laravel and PHP versions does spinen/laravel-geometry support?
- The package's supported Laravel and PHP versions are determined by its Composer constraints, and the last release was in June 2020. That makes compatibility with modern Laravel and PHP 8+ uncertain without testing. Check the composer.json constraints and run a sandbox proof of concept before adopting it.
- Which databases and spatial extensions work with laravel-geometry?
- It depends on a spatial-capable database, so validate MySQL or MariaDB spatial types and PostgreSQL with PostGIS separately if you use both. The package itself is only the PHP hydration layer; indexing and spatial functions remain database-native. Confirm geometry type coverage, SRID behavior, and migration support for your chosen database.
- How do I cast a geometry column to a geoPHP object in Eloquent?
- Define the spatial column in your migration with the database's geometry type, then add the package's cast to the Eloquent model so reads and writes become geoPHP geometry objects. Test round trips for representative points, lines, polygons, empty values, and large geometries. Keep geoPHP objects at the infrastructure boundary rather than leaking them through domain services.
- Does laravel-geometry support WKT, WKB, and GeoJSON?
- The package is built around geoPHP, so serialization formats such as WKT, WKB, and GeoJSON are primarily governed by geoPHP and your database driver. Validate how your chosen database returns geometry values and how the cast exposes them in model serialization. Test malformed inputs, empty geometries, and API output explicitly.
- How are SRIDs and geometry types handled in laravel-geometry?
- SRID handling and geometry type coverage are key integration risks because the package is a thin adapter over geoPHP and the database. Confirm whether SRID mismatches are detected or silently transformed, and test the specific geometry types you need. Do not assume advanced type or SRID support without contract tests.
- Can I use laravel-geometry for distance queries, routing, or GIS analytics?
- No, it is not a GIS analytics or routing engine. Use database-native spatial functions for filtering, distance, containment, and indexing, and keep heavy spatial computation in the database or a dedicated geospatial service. The package is best for basic Eloquent hydration and serialization of geometry values.
- Is spinen/laravel-geometry actively maintained and production-ready?
- Treat it as a tactical adapter rather than a strategic dependency. The last release was 2020-06-19, adoption is low at 41 stars, and it depends on geoPHP, so expect maintenance and compatibility risk. Assign an internal owner, pin versions, audit dependencies, and avoid business-critical use without a fork or replacement plan.
- What are alternatives or an exit strategy if laravel-geometry is abandoned?
- Alternatives include a custom Eloquent cast backed by native SQL, an actively maintained geometry library, or database-native spatial queries with minimal PHP hydration. Introduce an internal geometry adapter or repository contract so the package is an implementation detail. That lets you fork, patch, or replace spinen/laravel-geometry without rewriting domain logic.