PHPackages                             m1ke/sql-geo - 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. m1ke/sql-geo

ActiveLibrary

m1ke/sql-geo
============

Easily store GeoJSON in a SQL database

0824PHP

Since Jan 20Pushed 11y ago1 watchersCompare

[ Source](https://github.com/M1ke/sql-geo)[ Packagist](https://packagist.org/packages/m1ke/sql-geo)[ RSS](/packages/m1ke-sql-geo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

SQL Geo I/O
===========

[](#sql-geo-io)

A PHP library for moving data between database and standard output formats (e.g. `GeoJSON` and `KML`).

Initially created just as a wrapper to take GeoJSON data and input into a database.

### Installation

[](#installation)

`php composer.phar require m1ke/geojson-sql`

### Authors

[](#authors)

Written by [Mike Lehan](http://twitter.com/m1ke) and [StuRents.com](http://sturents.com).

### Usage

[](#usage)

- For `GeoJsonSql`
    - `process_and_save()` Returns the `$polygon` array formatted for inclusion in a query. Also accepts a PDO statement if you want to save in a database.
    - `process_with_query(PDO $db,$table,$name)` Creates a PDO query with a single value which is replaced with the polygon
- For `SqlGeo`
    - `search_json(Array $where)` Returns a JSON string based on the submitted query e.g. `['item_id' => 25]`

### Example

[](#example)

For GeoJsonSql:

```
require __DIR__.'/vendor/autoload.php';

$db=new PDO('mysql:host=localhost;dbname=database','user','pass');

$file_name='geojson.json';

$geojson = new GeoJsonSql($file_name);
$geojson->process_with_query($db,'table','polygon_field');

```

For SqlGeo:

```
require __DIR__.'/vendor/autoload.php';

$db=new PDO('mysql:host=localhost;dbname=geospatial','root','');

$sqljson=new SqlGeo($db,'table','polygon_field');
echo $sqljson->search_json(['title'=>'Polygon Title']);

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e13cb42c1a004c15c986cc3ac59424757dd04b25ed4068146e41812f0410338?d=identicon)[m1ke](/maintainers/m1ke)

---

Top Contributors

[![M1ke](https://avatars.githubusercontent.com/u/1226123?v=4)](https://github.com/M1ke "M1ke (46 commits)")

### Embed Badge

![Health badge](/badges/m1ke-sql-geo/health.svg)

```
[![Health](https://phpackages.com/badges/m1ke-sql-geo/health.svg)](https://phpackages.com/packages/m1ke-sql-geo)
```

PHPackages © 2026

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