- How do I install plin-code/kml-parser in a Laravel app?
- Run composer require plin-code/kml-parser, then publish the config with php artisan vendor:publish --tag=kml-parser-config if you need to customize defaults. The package uses a Laravel service provider and config publishing, so it fits standard Laravel 8+ projects. After publishing, review config/kml-parser.php for namespace and temporary directory settings.
- Does plin-code/kml-parser support both KML and KMZ files?
- Yes, the package parses KML files and also handles compressed KMZ files by unzipping them internally. That reduces client-side preprocessing for KMZ uploads. KMZ handling relies on Flysystem and the zip extension, so confirm those are available in your deployment.
- How do I parse a KML file and retrieve placemarks with plin-code/kml-parser?
- Instantiate PlinCode\KmlParser\KmlParser, call loadFromFile with the KML path, then use getPlacemarks to retrieve points of interest. The parser also exposes getStyles, getStyleMaps, getDocumentName, and document description details. The resulting structured data can be transformed into your own models or API responses.
- What dependencies and PHP extensions does plin-code/kml-parser need?
- The technical evaluation notes reliance on spatie/flysystem for KMZ handling and simplexml for KML parsing. Your server should have the xml, zip, and fileinfo PHP extensions enabled, which are common in Laravel deployments. Check composer.json for exact dependency and PHP version constraints before upgrading.
- Can I parse a KMZ file stored in Laravel storage or on S3?
- KMZ support is built in and uses Flysystem, so the package is compatible with local, S3, or other configured storage adapters. The evaluation references a storage-based KMZ parsing path, while the README excerpt shows the core parser API. Confirm the current method names in the repository README before wiring it into upload or storage workflows.
- What is the output format of parsed KML data and how do I save it to a database?
- The package returns structured arrays or objects such as features, coordinates, properties, placemarks, styles, and style maps. It does not automatically persist to your database, so you map the parsed data to Eloquent models, raw SQL, or PostGIS geometry columns yourself. For geospatial querying, PostgreSQL with PostGIS is recommended.
- Is plin-code/kml-parser compatible with Laravel 8 and PHP 8?
- The technical assessment states the package is tested with Laravel 8+ and requires PHP 8.0+. It follows Laravel-native patterns such as service providers and config publishing. Always verify the exact Laravel and PHP ranges in the package composer.json for your project.
- How do I avoid memory issues when parsing large KML or KMZ files?
- Large KML/KMZ files are a known performance risk, so test parsing with your expected file sizes before production. Use queue jobs, chunked or streaming parsing where possible, and avoid loading unnecessary data into memory. The evaluation recommends memory optimization and batch processing for heavy geospatial imports.
- Does plin-code/kml-parser validate malformed KML or KMZ XML?
- There is no built-in KML schema validation for structure correctness, so malformed XML may need custom error handling. Add try/catch logic, logging, retries, or alerts around parsing jobs. For edge cases, validate inputs against the OGC KML specification and test with representative files.
- How do I change the default KML namespace or KMZ temp directory?
- Publish the package config and edit config/kml-parser.php. The namespace defaults to http://www.opengis.net/kml/2.2, and temp_directory set to null uses the system temporary directory for KMZ extraction. Override those values when your KML tags or storage environment require it.