PHPackages                             myclar/kamel-php - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. myclar/kamel-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

myclar/kamel-php
================

A PHP KML parser library

v1.0.1(1y ago)23BSD-3-ClausePHP

Since Jan 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/alexboia/KML-for-PHP)[ Packagist](https://packagist.org/packages/myclar/kamel-php)[ RSS](/packages/myclar-kamel-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

KML for PHP library (KamelPhp)
==============================

[](#kml-for-php-library-kamelphp)

A PHP KML parser library initially developed as part of the [WP-Trip-Summary WordPress plug-in](https://github.com/alexboia/WP-Trip-Summary/). It is based on [Stepan Daleky's KML parser on GitLab](https://gitlab.com/stepandalecky/kml-parser) and has now been extracted as a separate library to ease up on the code base a bit.

About
-----

[](#about)

Supported KML entities:

- `Kml` class (`` root element);
- `Folder` and `Document` classes (and elements) as `Container` types and direct children of the KML root;
- Abstract `Feature` class and element, with support for the following attributes: `id`, `styleUrl`, `name`, `description`, `open`, `visibility`, `address`, `phoneNumber`;
- `Placemark` class and element, with support for `Point`, `Linestring`, `LinearRing`, `Polygon` and `MultiGeometry` geometries as well as `Style` and `ExtendedData`.

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

[](#installation)

Install the latest version with:

```
composer require myclar/kamel-php

```

### Using the parser directly

[](#using-the-parser-directly)

The parser class simply parses a KML string (or a file that contains a KML string) and returns an object graph:

```
use KamelPhp\KmlParser\Parser;

$kmlParser = Parser::fromString($fileContents);
//OR
$kmlParser = Parser::fromFile($filePath);

//And then get the KML root and do your thing with it.
$kml = $kmlParser->getKml();
```

Some samples:

- The built-in [`Processor`](https://github.com/alexboia/KML-for-PHP/blob/main/src/KmlParser/Processor.php)
- The [current set of tests for the parser class](https://github.com/alexboia/KML-for-PHP/blob/main/tests/LibKmlParserTests.php)

### Using the processor

[](#using-the-processor)

The [processor class](https://github.com/alexboia/KML-for-PHP/blob/main/src/KmlParser/Processor.php) provides a simple and expedient way of traversing a KML document, while allowing a certain degree of customization. Its usage is not mandatory.

Limitations:

- Either root KML folder or root KML document is considered, not both (first it checks for a root folder and, if not found for a root document);
- A KML container is searched, in this order, for: folders, documents and placemarks;
- Neither folder, nor document metadata is stored;
- For a placemark, only the name and description metadata items are stored and reported;
- Order in which various document parts are processed cannot be altered;
- Visibility, as specified by the `visibility` feature attribute, is not accounted for.

In order to use the processor, you need to provide a mandatory delegate (a class implementing [`KamelPhp\KmlParser\Processor\Delegate`](https://github.com/alexboia/KML-for-PHP/blob/main/src/KmlParser/Processor/Delegate.php)) which you can use to:

- control what gets reported back to you (`Delegate::shouldXYZ()` methods, e.g. return `false` from `Delegate::shouldProcessPointGeometry()` if you do not what to have KML points sent back to you.);
- process KML primitives as they are found and reported back to you (e.g. implement `Delegate::processPoint()` to process KML points);
- react when processing begins (`Delegate::begin()`) and ends (`Delegate::end()`);
- react when an error occurs (`Delegate::error()`).

As it may already be obvious, the way it works sort of breaks the tree structure, but that's perfectly acceptable in my use case - obtain relevant geometries for simple map drawing.

It's up to yo what the delegate does, either it stores the artefacts somewhere or it builds some representation in memory and provides a way to access it at the end. See [here an example implementation](https://github.com/alexboia/WP-Trip-Summary/blob/master/lib/route/track/documentParser/kml/LibKmlProcessorDelegate.php).

```
use KamelPhp\KmlParser\Parser;

$delegate = new MyDelegate();
$processor = new Processor($delegate);
$processor->processKmlString($sourceString);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance42

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~14 days

Total

2

Last Release

483d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9aa8a718bfec878a514a5aefdbf168f9c51a43906a13df80172a6fb0047c5646?d=identicon)[alexandru.boia](/maintainers/alexandru.boia)

---

Top Contributors

[![alexboia](https://avatars.githubusercontent.com/u/280100?v=4)](https://github.com/alexboia "alexboia (13 commits)")

---

Tags

kmllibraryparserphpprocessorphpparserlibrarykml

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/myclar-kamel-php/health.svg)

```
[![Health](https://phpackages.com/badges/myclar-kamel-php/health.svg)](https://phpackages.com/packages/myclar-kamel-php)
```

###  Alternatives

[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k910.8M118](/packages/doctrine-lexer)[thunderer/shortcode

Advanced shortcode (BBCode) parser and engine for PHP

3892.6M44](/packages/thunderer-shortcode)[simplehtmldom/simplehtmldom

A fast, simple and reliable HTML document parser for PHP.

1921.3M14](/packages/simplehtmldom-simplehtmldom)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23483.5k2](/packages/corveda-php-sandbox)[leonelquinteros/php-toml

PHP parser for TOML language ( https://github.com/toml-lang/toml )

266.7k](/packages/leonelquinteros-php-toml)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)

PHPackages © 2026

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