PHPackages                             teamzac/laravel-shapefiles - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. teamzac/laravel-shapefiles

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

teamzac/laravel-shapefiles
==========================

A wrapper for gasparesganga/php-shapefile with a Laravel-ish collections API

v0.6.1(1mo ago)36672MITPHPPHP &gt;=8.0

Since Mar 8Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/teamzac/laravel-shapefiles)[ Packagist](https://packagist.org/packages/teamzac/laravel-shapefiles)[ Docs](https://github.com/teamzac/laravel-shapefiles)[ RSS](/packages/teamzac-laravel-shapefiles/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (10)Versions (10)Used By (0)

A Laravel Collection style API for gasparesganga/php-shapefile
==============================================================

[](#a-laravel-collection-style-api-for-gasparesgangaphp-shapefile)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c1ac4ef8024b5b284a8e19d2f57a8874a2e2284c157feade40ca2d3c0cef24ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465616d7a61632f6c61726176656c2d736861706566696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teamzac/laravel-shapefiles)

The [gasparesganga/php-shapefile](https://www.github.com/gasparesganga/php-shapefile) package is extremely handy for working directly with Shapefiles, but we work mostly in Laravel and prefer the collection-style APIs found throughout. This package simply wraps the original ShapefileReader class in a LazyCollection to make iterating on it a bit more familiar.

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

[](#installation)

You can install the package via composer:

```
composer require teamzac/laravel-shapefiles
```

Usage
-----

[](#usage)

```
$reader = new TeamZac\LaravelShapefiles\Reader('file_or_directory_path_here');

$reader->count(); // total number of records
$reader->each(function($geometry) {
    // do something
});
```

You can pass a reference to the .shp file, or the directory containing the .shp file, when instantiating the Reader.

When iterating in the original package, you'd receive an instance of `Shapefile\Geometry\Geometry`. We also wrap this in a class that adds a couple of additional methods:

```
...
$reader->each(function($geometry) {
    $geometry->asGeoJson(); // passes through to the getGeoJSON() method with the "as" verbiage commonly used in Laravel
    $geometry->asJson(); // a convenience method that runs the GeoJSON through json_decode first
    $geometry->getData('ID'); // allows retreival of a specific key in the data array
    $geometry->ID; // you can also access the data array as properties on the Geometry class

    $geometry->getDataArray(); // methods are passed through to the underlying Shapefile\Geometry\Geometry class
    $geometry->getRaw(); // you can retrieve the underlying Shapefile\Geometry\Geometry class with the getRaw() method
});
...
```

### To-do

[](#to-do)

We don't currently implement a wrapper around the ShapefileWriter class, since we don't use it. That might be added one day if we need it.

### Testing

[](#testing)

```
composer test
```

The package comes with a small shapefile containing two polygons. Note, we've only tested this with polygons but there's no reason why it shouldn't work with any other kind of feature.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Gaspare Sganga](https://github.com/gasparesganga/php-shapefile) - Author of the underlying package
- [Chad Janicek](https://github.com/team-zac)
- [Laravel Package Boilerplate](https://laravelpackageboilerplate.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance90

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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.

###  Release Activity

Cadence

Every ~231 days

Recently: every ~436 days

Total

9

Last Release

46d ago

PHP version history (3 changes)v0.1PHP ^7.1

0.3PHP ^7.1|^8.0

v0.5.0PHP &gt;=8.0

### Community

Maintainers

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

---

Top Contributors

[![chadjanicek](https://avatars.githubusercontent.com/u/18754689?v=4)](https://github.com/chadjanicek "chadjanicek (18 commits)")

---

Tags

laravelShapefile

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/teamzac-laravel-shapefiles/health.svg)

```
[![Health](https://phpackages.com/badges/teamzac-laravel-shapefiles/health.svg)](https://phpackages.com/packages/teamzac-laravel-shapefiles)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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