PHPackages                             plin-code/kml-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. plin-code/kml-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

plin-code/kml-parser
====================

A Laravel package to parse KML and KMZ files

v1.0.2(1y ago)3977—10%[3 PRs](https://github.com/plin-code/kml-parser/pulls)MITPHPPHP ^8.3CI passing

Since Apr 8Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/plin-code/kml-parser)[ Packagist](https://packagist.org/packages/plin-code/kml-parser)[ Docs](https://github.com/plin-code/kml-parser)[ GitHub Sponsors](https://github.com/PlinCode)[ RSS](/packages/plin-code-kml-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (6)Used By (0)

Laravel KML Parser
==================

[](#laravel-kml-parser)

[![Latest Version on Packagist](https://camo.githubusercontent.com/16f20013c4089e6c2d982e9f32b05aa9a23b6a753935882e2b2e38385f05ae25/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706c696e2d636f64652f6b6d6c2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plin-code/kml-parser)[![GitHub Tests Action Status](https://camo.githubusercontent.com/fa35a246ea72fe970afc25d0bf7d0dcf8cddeae5ef840c3be483ba489f6ef2cd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c696e2d636f64652f6b6d6c2d7061727365722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/plin-code/kml-parser/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/da8945f208a8f453547c0db4db0c19577facc2176b3c5ae0454683f55d5ab6f6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c696e2d636f64652f6b6d6c2d7061727365722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/plin-code/kml-parser/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4a543c4fd7834326a0eb3122df9eb1c66febf20d911a39b46e5ffa8560d3d059/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706c696e2d636f64652f6b6d6c2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plin-code/kml-parser)

A simple Laravel package to parse KML and KMZ files, extracting geographic data in a convenient format.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require plin-code/kml-parser
```

You can publish the config file with:

```
php artisan vendor:publish --tag="kml-parser-config"
```

This is the contents of the published config file:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Default KML Namespace
    |--------------------------------------------------------------------------
    |
    | This value is the default namespace used for parsing KML files.
    | Usually you don't need to change this.
    |
    */
    'namespace' => 'http://www.opengis.net/kml/2.2',

    /*
    |--------------------------------------------------------------------------
    | Temporary Directory
    |--------------------------------------------------------------------------
    |
    | This value determines the temporary directory used for extracting KMZ files.
    | If null, the system temp directory will be used.
    |
    */
    'temp_directory' => null,
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use PlinCode\KmlParser\KmlParser;

// Parse a KML file
$parser = new KmlParser();
$parser->loadFromFile('path/to/file.kml');

// Get placemarks (points of interest)
$placemarks = $parser->getPlacemarks();

// Get styles
$styles = $parser->getStyles();

// Get style maps
$styleMaps = $parser->getStyleMaps();

// Get document name and description
$name = $parser->getDocumentName();
$description = $parser->getDocumentDescription();

// Convert to GeoJSON
$geoJson = $parser->toGeoJson();
```

### Working with KMZ Files

[](#working-with-kmz-files)

KMZ files are ZIP archives that contain a KML file and possibly other assets like images:

```
// Parse a KMZ file
$parser = new KmlParser();
$parser->loadFromKmz('path/to/file.kmz');

// Work with the data just like with KML
$placemarks = $parser->getPlacemarks();
```

Extract all files from a KMZ:

```
use PlinCode\KmlParser\KmzExtractor;

$extractor = new KmzExtractor();
$files = $extractor->extractAllFiles('path/to/file.kmz', 'extraction/directory');
```

### Facade Usage

[](#facade-usage)

You can also use the provided facade:

```
use PlinCode\KmlParser\Facades\KmlParser;

$placemarks = KmlParser::loadFromFile('path/to/file.kml')->getPlacemarks();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Daniele Barbaro](https://github.com/plin-code)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance69

Regular maintenance activity

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

401d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7653cedfb706bdbaceab17cb57fa55d5e2744faeb722cfc1e2af8c3fd88f13ef?d=identicon)[danielebarbaro](/maintainers/danielebarbaro)

---

Top Contributors

[![danielebarbaro](https://avatars.githubusercontent.com/u/4376886?v=4)](https://github.com/danielebarbaro "danielebarbaro (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

hacktoberfesthacktoberfest2025kml-fileskml-parserkmzlaravel-packagelaravellaravel-packagemapsgeospatialkmldanielebarbaroPlinCodekmzplin-codekml-parserlaravel-kmllaravel-kmz

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/plin-code-kml-parser/health.svg)

```
[![Health](https://phpackages.com/badges/plin-code-kml-parser/health.svg)](https://phpackages.com/packages/plin-code-kml-parser)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
