https://github.com/jbelien/mapfile-php-library
PHP Library to read/write MapServer mapfiles
https://github.com/jbelien/mapfile-php-library
library mapfile mapscript mapserver php php-library
Last synced: 8 months ago
JSON representation
PHP Library to read/write MapServer mapfiles
- Host: GitHub
- URL: https://github.com/jbelien/mapfile-php-library
- Owner: jbelien
- License: gpl-2.0
- Created: 2015-09-03T12:22:05.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-01-01T13:45:06.000Z (about 2 years ago)
- Last Synced: 2025-05-31T17:32:42.827Z (9 months ago)
- Topics: library, mapfile, mapscript, mapserver, php, php-library
- Language: PHP
- Homepage:
- Size: 1.08 MB
- Stars: 8
- Watchers: 2
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# MapFile-PHP-Library
[](https://packagist.org/packages/jbelien/mapfile-php-library)
[](https://packagist.org/packages/jbelien/mapfile-php-library)
[](https://packagist.org/packages/jbelien/mapfile-php-library)
[](LICENSE)
PHP Library to read/write MapServer mapfiles.
This library is based on [MapServer 7.2.0 documentation](https://mapserver.org/mapfile/) (last updated on 16 June 2017).
## Installation
```cmd
composer require jbelien/mapfile-php-library
```
## Usage
### Write MapFile (example)
```php
$map = new \MapFile\Model\Map();
$map->name = 'my-mapfile';
$map->projection = 'EPSG:4326';
$map->scalebar = new \MapFile\Model\Scalebar();
$map->scalebar->units = 'kilometers';
$layer = new \MapFile\Model\Layer();
$layer->name = 'my-layer';
$layer->type = 'POLYGON';
$layer->status = 'ON';
$layer->data = 'my-shapefile';
$layer->projection = 'EPSG:4326';
$class = new \MapFile\Model\LayerClass();
$style = new \MapFile\Model\Style();
$style->color = [0, 0, 0];
$class->style->add($style);
$label = new \MapFile\Model\Label();
$label->text = '[label]';
$label->color = [0, 0, 0];
$label->size = 12;
$class->label->add($label);
$layer->class->add($class);
$map->layer->add($layer);
(new \MapFile\Writer\Map($map))->save('my-mapfile.map');
```
Have a look at the [source code](https://github.com/jbelien/MapFile-PHP-Library/tree/master/src/Model) to see all the available options.
### Parse MapFile (example)
```php
$map = (new \MapFile\Parser\Map())->parse('my-mapfile.map');
foreach ($map->layer as $layer) {
echo $layer->name;
}
```