- How do I install phayes/geophp in a Laravel application?
- Install it with Composer using composer require phayes/geophp; there are no runtime services or PHP extensions required for the core parsing path. geoPHP is a plain library, so it ships no Laravel service provider, config file, or facade. You bind it yourself with a thin wrapper class registered as a singleton in a service provider, and use that wrapper for exception handling, input size guards, and logging.
- Which geospatial formats does geoPHP support for reading and writing?
- geoPHP can parse and serialize WKT, WKB, GeoJSON, KML, GPX, and GeoRSS, plus a few legacy formats. You load data with geoPHP::load($data, 'kml') and write it out with ->out('geojson'). This makes it a practical anti-corruption layer for normalizing uploads, partner API payloads, and feed files into a single canonical format before storage.
- Do I need the GEOS PHP extension to use geoPHP?
- No, not for parsing and format conversion, which work in pure PHP with no extensions. GEOS is only needed for topological operations such as intersect, union, buffer, and convex hull on complex geometries. Without GEOS those operations are unavailable or numerically fragile, so treat GEOS availability as a deliberate deployment decision and pin it in every environment, including CI.
- Can geoPHP perform spatial predicates and overlays like intersects, union, or buffer?
- Only in a limited way, and reliably only when the GEOS PHP extension is loaded. Without GEOS, pure-PHP topology on real-world data can produce invalid polygons, self-intersections, and precision drift. If your product depends on correct spatial answers, such as billing by region or eligibility by boundary, do the compute in PostGIS or GEOS and keep geoPHP for parsing.
- Does phayes/geophp work with Laravel 10, Laravel 11, and PHP 8.2 or 8.3?
- The library has no Laravel dependency, so framework version is not the issue; PHP version drift is. Codebases of this vintage commonly surface PHP 8.x deprecations such as dynamic properties, implicit nullable parameters, and string or array coercion. Run a compatibility spike against your actual PHP 8.2 or 8.3 target before committing, and expect to own any patches you need.
- What license does phayes/geophp use, and can I use it commercially?
- GitHub reports the license as NOASSERTION, and geoPHP has historically carried a GPL-2.0 and BSD dual notice. A GPL reading on a distributed or SaaS-adjacent product is a legal blocker rather than an engineering preference. Get a written position from counsel before writing any code against it.
- How do I convert a KML or GPX file to GeoJSON in PHP?
- Load the payload with the matching adapter and serialize it out, for example geoPHP::load($kml, 'kml')->out('geojson'). The same pattern works for GPX, WKT, and WKB inputs. Be aware that geometry is held fully in memory as PHP objects with no streaming path, so a dense parcel polygon or a large KML can exhaust memory_limit; enforce upload size limits in your wrapper.
- Does geoPHP handle SRIDs and coordinate reprojection?
- No. geoPHP has no projection engine worth relying on, so anything requiring reprojection must go through proj4 bindings or PostGIS ST_Transform. Use geoPHP to parse and normalize the payload, then hand the coordinates to the tool that owns projection. Do not let the library become the system of record for coordinate reference systems.
- Is phayes/geophp still actively maintained?
- Barely. It has roughly 875 GitHub stars but a low activity signal, and the 2.x line has been in progress for years with only sporadic upstream commits. Plan on owning patches and security review yourself, and avoid assuming fixes will land upstream. Its stable value is parsing and format conversion, not rapidly evolving capability.
- What are good alternatives to phayes/geophp for Laravel projects?
- If you need real spatial queries, PostGIS is the answer, with geoPHP reduced to a parser at the edges. For pure-PHP geometry there are lighter packages, and for projection you want proj4php or PostGIS ST_Transform. Whichever you pick, hide it behind a GeometryService interface so swapping the implementation later stays a one-day change rather than a rewrite.