{"id":47312611,"url":"https://github.com/mbolli/php-geobuf","last_synced_at":"2026-04-02T13:59:53.218Z","repository":{"id":62526005,"uuid":"425358605","full_name":"mbolli/php-geobuf","owner":"mbolli","description":"PHP library for the geobuf compact geospatial format.","archived":false,"fork":false,"pushed_at":"2026-03-26T06:44:28.000Z","size":257,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-03-27T02:08:20.030Z","etag":null,"topics":["geobuf","geojson","json","php","protobuf","topojson"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbolli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"mbolli","custom":"https://paypal.me/bolli"}},"created_at":"2021-11-06T22:06:30.000Z","updated_at":"2026-03-26T06:44:13.000Z","dependencies_parsed_at":"2024-07-31T12:29:17.374Z","dependency_job_id":null,"html_url":"https://github.com/mbolli/php-geobuf","commit_stats":{"total_commits":50,"total_committers":1,"mean_commits":50.0,"dds":0.0,"last_synced_commit":"afdf668296aae5d9cc877811d8737572d2ec58d6"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mbolli/php-geobuf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbolli%2Fphp-geobuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbolli%2Fphp-geobuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbolli%2Fphp-geobuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbolli%2Fphp-geobuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbolli","download_url":"https://codeload.github.com/mbolli/php-geobuf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbolli%2Fphp-geobuf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31307441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geobuf","geojson","json","php","protobuf","topojson"],"created_at":"2026-03-17T12:27:37.638Z","updated_at":"2026-04-02T13:59:53.211Z","avatar_url":"https://github.com/mbolli.png","language":"PHP","funding_links":["https://github.com/sponsors/mbolli","https://paypal.me/bolli"],"categories":[],"sub_categories":[],"readme":"# php-geobuf\n\n[![php-geobuf test suite](https://github.com/mbolli/php-geobuf/actions/workflows/php-test.yml/badge.svg)](https://github.com/mbolli/php-geobuf/actions/workflows/php-test.yml) [![Latest Stable Version](https://poser.pugx.org/mbolli/php-geobuf/v)](https://packagist.org/packages/mbolli/php-geobuf) [![Total Downloads](https://poser.pugx.org/mbolli/php-geobuf/downloads)](https://packagist.org/packages/mbolli/php-geobuf) [![Latest Unstable Version](https://poser.pugx.org/mbolli/php-geobuf/v/unstable)](https://packagist.org/packages/mbolli/php-geobuf) [![License](https://poser.pugx.org/mbolli/php-geobuf/license)](https://packagist.org/packages/mbolli/php-geobuf) [![PHP Version Require](https://poser.pugx.org/mbolli/php-geobuf/require/php)](https://packagist.org/packages/mbolli/php-geobuf)\n\nPHP library for the geobuf compact geospatial format.\n\nThis is essentially a PHP port of the great [pygeobuf](https://github.com/pygeobuf/pygeobuf).\n\nGeobuf stores GeoJSON 6-8 times smaller and TopoJSON 2-3 times smaller. Depending on the `$precision` attribute, lossless compression is possible. More information about Geobuf is available in the [JS implementation](https://github.com/mapbox/geobuf) or the [Python implementation](https://github.com/pygeobuf/pygeobuf).\n\n**Quick size comparison:** An example 745 kB GeoJSON was converted to a 90 kB Geobuf file – more than 8 times less.\n\n**Beware:** Experimental state – it works for my purposes but there probably are some bugs.\n\n## Installation\n\n```bash\ncomposer require mbolli/php-geobuf\n```\n\n## Usage\n\nThe following methods are exposed:\n\n### Encoder\n\n- `encode()` reads a JSON string. Returns a geobuf-encoded string\n  - string `$dataJson` a JSON string\n- `encodeToFile()` reads a JSON string and writes to a file. Returns the filesize of the resulting file or false\n  - string `$filePath` where to store the resulting geobuf file\n  - string `$dataJson` a JSON string\n- `encodeFileToBufFile()` reads from a JSON file and writes to a file. Returns the filesize of the resulting file or false\n  - string `$jsonFile` path to the JSON file\n  - string `$geobufFile` where to store the resulting geobuf file\n- `encodeFileToBuf()` reads from a JSON file. Returns a geobuf-encoded string\n  - string `$fileName` path to the JSON file\n\nAll encoding methods support the following two non-mandatory arguments:\n\n- int `$precision` max number of digits after the decimal point in coordinates, 6 by default (10 cm).\n- int `$dim` number of dimensions in coordinates, 2 by default.\n\n### Decoder\n\n- `decodeToArray()` returns a PHP array\n  - string `$encodedInput` geobuf input\n- `decodeFileToArray()` returns a PHP array\n  - string `$fileName` path to the geobuf file\n- `decodeToJson()` returns a JSON string\n  - string `$encodedInput` geobuf input\n- `decodeFileToJson()` returns a JSON string\n  - string `$fileName` path to the geobuf file\n- `decodeFileToJsonFile()` writes to a file and returns the filesize of the resulting JSON file or false\n  - string `$geobufFile` path to the geobuf file\n  - string `$jsonFile` where to store the resulting JSON file\n  \n### Example\n\n```php\n\u003c?php\n\nrequire_once('./vendor/autoload.php');\n\n$jsonFile = './my.geojson';\n$geobufFile = basename($jsonFile) . '.geobuf';\ntry {\n    // encodes a json string to geobuf\n    $geobufString = \\MBolli\\PhpGeobuf\\Encoder::encode(\n        file_get_contents($jsonFile), // (string) a json string \n        6, // (int) precision: max number of digits after the decimal point in coordinates, 6 by default\n        2 // (int) dimensions: number of dimensions in coordinates, 2 by default.\n    );\n    \n    // decodes a geobuf file to json\n    $jsonString = \\MBolli\\PhpGeobuf\\Decoder::decodeToJson(\n        file_get_contents($geobufFile) // (string) expects a geobuf string\n    )\n\n} catch (\\MBolli\\PhpGeobuf\\GeobufException $e) {\n    var_dump($e);\n} catch (\\Throwable $e) {\n    var_dump($e);\n}\n```\n\n## Contribute\n\nPull requests are encouraged. Code style is enforced by PHP-CS-Fixer:\n\n```bash\ncomposer run lint # lint source files and show problems (read-only)\ncomposer run lint-diff # lint source files and show diff to the files fixed state (read-only)\ncomposer run fix # lint source files and fix the problems\ncomposer run test # execute all tests\ncomposer run analyse # run phpstan static analyzer\n```\n\nIf the PR is about the Encoder or Decoder, please add a test JSON to the `tests/geojson` folder. The test suite will automatically pick it up and test it when executed.\n\n## Background: Proto compilation\n\nClasses were generated by the [proto compiler](https://developers.google.com/protocol-buffers) using this command:\n\n```bash\nbin/protoc --proto_path=src --php_out=build src/geobuf.proto\n```\n\nUsed was [this proto file](./geobuf.proto), lightly modified from the [mapbox/geobuf proto file](https://github.com/mapbox/geobuf/blob/master/geobuf.proto) for proto3 compatibility and automated namespace generation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbolli%2Fphp-geobuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbolli%2Fphp-geobuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbolli%2Fphp-geobuf/lists"}