abduns / laravel-gpx-reader
A Laravel package to read and work with GPX 1.1 files.
v2.0.4
2026-05-17 12:32 UTC
Requires
- php: ^8.2
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
A Laravel package to read and work with GPX 1.1 files.
Features
- Modern PHP support
- GPX 1.1 Support
- No External Dependencies
- Laravel Integration
- Type-Safe DTOs
- Validation with strict mode
Installation
composer require abduns/laravel-gpx-reader
Quick Start
use Dunn\GpxReader\Facades\Gpx; // From file $gpx = Gpx::parseFromFile('path/to/file.gpx'); echo $gpx->creator;
Why This Package?
- Existing solutions are outdated
- Missing modern PHP features
- Poor developer experience
- No standards compliance
- Too framework-coupled
This package focuses on simplicity, interoperability, and modern developer ergonomics.
Usage
Basic Usage
use Dunn\GpxReader\Facades\Gpx; // From file $gpx = Gpx::parseFromFile('path/to/file.gpx'); // From string $gpx = Gpx::parseFromString($xmlString);
Advanced Usage
// Access metadata echo $gpx->creator; echo $gpx->version; if ($gpx->metadata) { echo $gpx->metadata->name; echo $gpx->metadata->desc; echo $gpx->metadata->time?->format('Y-m-d H:i:s'); } // Access Waypoints foreach ($gpx->waypoints as $waypoint) { echo "Waypoint: {$waypoint->name} ({$waypoint->latitude}, {$waypoint->longitude})"; echo " - Elevation: {$waypoint->elevation}"; // Access elevation } // Access Routes foreach ($gpx->routes as $route) { echo "Route: {$route->name}"; foreach ($route->points as $point) { echo " - Point: {$point->latitude}, {$point->longitude}"; echo " - Elevation: {$point->elevation}"; // Access elevation } } // Access Tracks foreach ($gpx->tracks as $track) { echo "Track: {$track->name}"; foreach ($track->segments as $segment) { foreach ($segment->points as $point) { echo " - Point: {$point->latitude}, {$point->longitude}"; echo " - Elevation: {$point->elevation}"; // Access elevation } } }
Configuration
You can publish the config file with:
php artisan vendor:publish --tag="gpx-config"
return [ 'strict_mode' => true, // Throw exceptions for invalid GPX structure 'timezone' => 'UTC', ];
Standards / Specifications
- GPX 1.1 Schema
References:
Supported Features
| Feature | Support |
|---|---|
| GPX 1.1 parsing | ✅ |
| Track / Route / Waypoint | ✅ |
| Type-safe DTOs | ✅ |
Compatibility
| Platform | Supported |
|---|---|
| PHP 8.2+ | ✅ |
| Laravel 11.0+ | ✅ |
Design Goals
- Developer experience first
- Predictable APIs
- Minimal dependencies
- Strong typing
- Extensibility
- Interoperability
Architecture
- Facade for ease of use
- DTOs for parsed GPX elements
- Native XML parsing
Performance
| Operation | Time |
|---|---|
| Parse typical GPX | < 10ms |
Testing
composer test
Roadmap
- Add GPX generation/writing
- Support older GPX 1.0 schema
Contributing
Contributions, issues, and discussions are welcome.
Security
If you discover security issues, please report them responsibly.
License
MIT