plin-code/kml-parser
Parse KML and KMZ files in Laravel to extract placemarks, styles, style maps, and document metadata. Simple installation, configurable namespace and temp directory, with a clean API for reading geographic data.
<Folder> paths on each placemark (['Piemonte', 'Laghi']). In a Google My Maps export those layer names are usually business meaning — category, region, owner. Flattening them (what the package did before) would have silently destroyed data users curated.toGeoJson() means an imported file can be previewed on the existing Leaflet/Mapbox stack before commit — a "confirm what you're importing" step we can ship cheaply rather than building a KML renderer.Adopt when:
.kml/.kmz.Look elsewhere when:
gx: extensions). The maintainer's own v1.0.0 note says support is still evolving.For executives: This is a free, MIT-licensed building block that lets us ship "import a map file" in days instead of weeks. No license cost, no vendor contract, and no lock-in — the whole API is a handful of methods that we wrap in our own interface, so replacing it later touches one class, not the product. The risk is not the code quality (it has tests, static analysis at its strictest level, and a maintained changelog); the risk is that it's a single-maintainer project with almost no adoption. We mitigate that with our own wrapper, our own test coverage around the import flow, and a queue plus file-size limit so a bad upload can't take the app down. Recommendation: adopt behind a wrapper for non-core imports; revisit if geo becomes core or file sizes grow.
For engineering: Laravel package, MIT, plain PHP DOM/XPath, service provider + facade + publishable config. Handles KML and KMZ (zip), configurable namespace and temp directory, folder hierarchy on placemarks, GeoJSON export, and a validator plus exception hierarchy so bad input fails predictably rather than as a generic XML error. 91 tests, PHPStan level 9 with an empty baseline — unusual discipline for a package this small. Known trade-offs to design around: whole document in memory, no streaming, no internal size cap; arrays rather than DTOs; and the README drifts from reality (the config snippet is stale and the KMZ archive limits aren't documented) — publish the config and read the v3.1.0 release notes as the source of truth. Integration plan: one KmlImportService that branches on .kml vs .kmz, normalizes to our own DTO, and is invoked from a queued job with an upload byte ceiling enforced before the parser ever sees the file.
How can I help you explore Laravel packages today?