PHPackages                             deadbyback/php-cyrillic-shapefile - 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. deadbyback/php-cyrillic-shapefile

ActiveLibrary

deadbyback/php-cyrillic-shapefile
=================================

Modern PHP 8.3+ library to read and write ESRI Shapefiles with Cyrillic charset support, compatible with WKT and GeoJSON

v0.4.1(7mo ago)0169MITPHPPHP &gt;=8.3.0

Since Oct 5Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/deadbyback/php-shapefile)[ Packagist](https://packagist.org/packages/deadbyback/php-cyrillic-shapefile)[ RSS](/packages/deadbyback-php-cyrillic-shapefile/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)DependenciesVersions (12)Used By (0)

PHP Cyrillic Shapefile
======================

[](#php-cyrillic-shapefile)

PHP library to read and write ESRI Shapefiles with full Cyrillic charset support, compatible with WKT and GeoJSON.

This is a modernized fork of [gasparesganga/php-shapefile](https://github.com/gasparesganga/php-shapefile) with enhanced Cyrillic text handling and PHP 8.3+ compatibility.

Features
--------

[](#features)

- ✅ **Full PHP 8.3+ support** with typed properties, constants, and return types
- ✅ **Cyrillic charset support** - automatic detection and repair of broken encodings (Windows-1251, ISO-8859-1)
- ✅ Read and write ESRI Shapefiles (.shp, .shx, .dbf, .dbt, .prj, .cpg)
- ✅ Support for all standard shape types (Point, Polyline, Polygon, MultiPoint, Z/M variants)
- ✅ WKT (Well-Known Text) and GeoJSON conversion
- ✅ DBF field types: CHAR, DATE, LOGICAL, MEMO, NUMERIC, FLOAT
- ✅ Fluent interface for method chaining
- ✅ PSR-12 code style compliant
- ✅ No external dependencies

Requirements
------------

[](#requirements)

- **PHP &gt;= 8.3.0** (for older PHP versions, use [gasparesganga/php-shapefile](https://github.com/gasparesganga/php-shapefile))
- `mbstring` extension (usually enabled by default)

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

[](#installation)

```
composer require deadbyback/php-cyrillic-shapefile
```

Quick Start
-----------

[](#quick-start)

### Reading a Shapefile

[](#reading-a-shapefile)

```
use CyrillicShapefile\ShapefileReader;

$shapefile = new ShapefileReader('path/to/file.shp');

foreach ($shapefile as $record) {
    // $record is a Geometry object (Point, Linestring, Polygon, etc.)
    $data = $record->getDataArray();
    $coords = $record->getArray();

    echo "Record: " . json_encode($data) . "\n";
}
```

### Writing a Shapefile

[](#writing-a-shapefile)

```
use CyrillicShapefile\ShapefileWriter;
use CyrillicShapefile\Shapefile;
use CyrillicShapefile\Geometry\Point;

$shapefile = new ShapefileWriter('path/to/output.shp');

// Define structure
$shapefile->setShapeType(Shapefile::SHAPE_TYPE_POINT);
$shapefile->addCharField('NAME', 50);
$shapefile->addNumericField('POPULATION', 10, 0);

// Add records
$point = new Point(30.5164, 50.4536);
$point->setData('NAME', 'Київ');
$point->setData('POPULATION', 4700000);
$shapefile->writeRecord($point);

// Shapefile is automatically finalized and closed
```

Cyrillic Support
----------------

[](#cyrillic-support)

The library automatically detects and handles Cyrillic text in multiple encodings:

```
use CyrillicShapefile\ShapefileHelper;

// Automatic charset detection and repair
$fixed = ShapefileHelper::tryRepairStringCharset($brokenString);

// Supported charsets: Windows-1251, ISO-8859-1, UTF-8
```

What's New in v4.0.0
--------------------

[](#whats-new-in-v400)

This major version brings full PHP 8.3 compatibility with breaking changes:

- **Typed constants**: All class constants now have explicit types
- **Full type safety**: Parameter types and return types on all methods
- **Modern PHP**: Union types, nullable types, static return types
- **Bug fixes**: Fixed Iterator compatibility, undefined variables, namespace issues

See [CHANGELOG.md](CHANGELOG.md) for complete details.

Documentation
-------------

[](#documentation)

For detailed documentation and examples, visit the original project:

- [Original documentation](https://gasparesganga.com/labs/php-shapefile/) by Gaspare Sganga

Differences from Original
-------------------------

[](#differences-from-original)

This fork extends the original `gasparesganga/php-shapefile` with:

1. **PHP 8.3+ compatibility** - uses modern PHP features (typed constants, properties, etc.)
2. **Cyrillic charset handling** - enhanced support for Cyrillic text in DBF files
3. **Namespace change** - from `Shapefile` to `CyrillicShapefile`
4. **Bug fixes** - fixed several issues with undefined variables and type compatibility

License
-------

[](#license)

MIT License - Same as the original project

Credits
-------

[](#credits)

- Original library: [Gaspare Sganga](https://github.com/gasparesganga)
- Cyrillic support and PHP 8.3 upgrade: deadbyback

Contributing
------------

[](#contributing)

Issues and pull requests are welcome!

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance65

Regular maintenance activity

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~163 days

Recently: every ~281 days

Total

10

Last Release

215d ago

PHP version history (2 changes)v0.1PHP &gt;=5.4.0

v0.4.0PHP &gt;=8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/85d3fe555755f26bb339e2ab99af8efdd649417e65fc888595664c86852f53d2?d=identicon)[deadbyback](/maintainers/deadbyback)

---

Top Contributors

[![deadbyback](https://avatars.githubusercontent.com/u/48978780?v=4)](https://github.com/deadbyback "deadbyback (12 commits)")[![Chazie](https://avatars.githubusercontent.com/u/47242617?v=4)](https://github.com/Chazie "Chazie (2 commits)")

---

Tags

gisgeospatialphp8geojsoncyrillicwindows-1251ShapefileshpdbfshapeESRIwkt

### Embed Badge

![Health badge](/badges/deadbyback-php-cyrillic-shapefile/health.svg)

```
[![Health](https://phpackages.com/badges/deadbyback-php-cyrillic-shapefile/health.svg)](https://phpackages.com/packages/deadbyback-php-cyrillic-shapefile)
```

###  Alternatives

[gasparesganga/php-shapefile

PHP library to read and write ESRI Shapefiles, compatible with WKT and GeoJSON

1511.6M20](/packages/gasparesganga-php-shapefile)[phpmyadmin/shapefile

ESRI ShapeFile library for PHP

281.4M1](/packages/phpmyadmin-shapefile)[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4485.3M4](/packages/martin-georgiev-postgresql-for-doctrine)[jmikola/geojson

GeoJSON implementation for PHP

3109.0M77](/packages/jmikola-geojson)[muka/shape-reader

A PHP library to parse ESRI Shape files

1129.5k2](/packages/muka-shape-reader)[funiq/geophp

Open-source native PHP library for doing geometry operations. Can read and write a wide variety of formats: (E)WKT, (E)WKB, TWKB, GeoJSON, KML, GPX, GeoRSS. Works with all Simple-Feature geometries (Point, LineString, Polygon...) and can be used to get centroids, bounding-boxes, area, etc.

21114.4k1](/packages/funiq-geophp)

PHPackages © 2026

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