PHPackages                             itsjustvita/laravel-vector-tiles - 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. itsjustvita/laravel-vector-tiles

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

itsjustvita/laravel-vector-tiles
================================

Serve Mapbox Vector Tiles directly from PostGIS in Laravel

v0.1.2-alpha(2mo ago)20MITPHPPHP ^8.4CI passing

Since Apr 1Pushed 2mo agoCompare

[ Source](https://github.com/itsjustvita/laravel-vector-tiles)[ Packagist](https://packagist.org/packages/itsjustvita/laravel-vector-tiles)[ RSS](/packages/itsjustvita-laravel-vector-tiles/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependencies (12)Versions (4)Used By (0)

Laravel Vector Tiles
====================

[](#laravel-vector-tiles)

Serve Mapbox Vector Tiles (MVT) directly from PostGIS in Laravel. No separate tile server required.

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

[](#requirements)

- PHP 8.4+
- Laravel 13+
- PostgreSQL with PostGIS extension

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

[](#installation)

```
composer require itsjustvita/laravel-vector-tiles
php artisan vector-tiles:install
```

Usage
-----

[](#usage)

### Defining Layers

[](#defining-layers)

Layers can be defined in `config/vector-tiles.php` for static definitions, or via the fluent API in a service provider for dynamic, auth-aware layers.

**Config-based:**

```
// config/vector-tiles.php
'layers' => [
    'buildings' => [
        'table' => 'buildings',
        'geometry' => 'geom',
        'srid' => 4326,
        'properties' => ['id', 'name', 'type', 'height'],
        'min_zoom' => 12,
        'max_zoom' => 18,
    ],
],
```

**Fluent API:**

```
use ItsJustVita\VectorTiles\Facades\VectorTiles;

// In a service provider's boot() method
VectorTiles::layer('buildings')
    ->from(Building::query()->where('status', 'published'))
    ->geometry('geom')
    ->properties(['id', 'name', 'type', 'height'])
    ->minZoom(12)
    ->maxZoom(18);
```

Tiles are served at `GET /tiles/{layer}/{z}/{x}/{y}.mvt`.

### Auth-Aware Tiles

[](#auth-aware-tiles)

Combine middleware for access control with scopes for per-user data filtering:

```
VectorTiles::layer('buildings')
    ->from(Building::query())
    ->middleware(['auth:sanctum'])
    ->scope(fn (Builder $query, ?User $user) =>
        $user?->isAdmin() ? $query : $query->where('owner_id', $user?->id)
    );
```

### Cache Invalidation

[](#cache-invalidation)

Tile cache is automatically flushed when observed models change:

```
VectorTiles::layer('buildings')
    ->from(Building::query())
    ->invalidateOn(Building::class);
```

### GeoJSON Endpoint

[](#geojson-endpoint)

Each layer also exposes a GeoJSON endpoint with required bounding box filtering:

```
GET /geojson/{layer}?bbox=9.0,48.0,9.5,48.5&limit=500

```

### MapLibre Integration

[](#maplibre-integration)

Generate source configuration for MapLibre GL JS:

```
$source = VectorTiles::maplibreSource('buildings');
// Returns: ['type' => 'vector', 'tiles' => [...], 'minzoom' => 12, 'maxzoom' => 18]

$allSources = VectorTiles::maplibreSources();
```

Configuration
-------------

[](#configuration)

KeyDefaultDescription`prefix``tiles`URL prefix for tile routes`middleware``[]`Global middleware for all routes`cache.enabled``true`Enable tile caching`cache.store``null`Cache store (null = default)`cache.ttl``3600`Cache TTL in seconds`geojson.prefix``geojson`URL prefix for GeoJSON routes`geojson.default_limit``1000`Default feature limit`geojson.max_limit``5000`Maximum feature limitTesting
-------

[](#testing)

The package provides a fake driver for testing without PostGIS:

```
use ItsJustVita\VectorTiles\Facades\VectorTiles;

VectorTiles::fake();

$response = $this->get('/tiles/buildings/14/8532/5765.mvt');
$response->assertOk();

VectorTiles::assertTileRequested('buildings', 14, 8532, 5765);
```

How It Works
------------

[](#how-it-works)

The package uses PostGIS functions `ST_AsMVT` and `ST_AsMVTGeom` to render vector tiles server-side. Eloquent query builders are supported as layer sources, enabling standard Laravel scopes, relations, and authorization patterns to control tile content.

Tile caching uses Laravel's cache system with a key-registry approach for efficient per-layer flushing. Model observers can automatically invalidate cached tiles when source data changes.

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance84

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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 ~4 days

Total

3

Last Release

83d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21318499?v=4)[itsjustvita](/maintainers/itsjustvita)[@itsjustvita](https://github.com/itsjustvita)

---

Top Contributors

[![itsjustvita](https://avatars.githubusercontent.com/u/21318499?v=4)](https://github.com/itsjustvita "itsjustvita (6 commits)")

---

Tags

laravelpostgisgismvtmaplibrevector-tiles

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/itsjustvita-laravel-vector-tiles/health.svg)

```
[![Health](https://phpackages.com/badges/itsjustvita-laravel-vector-tiles/health.svg)](https://phpackages.com/packages/itsjustvita-laravel-vector-tiles)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M341](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M129](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M125](/packages/roots-acorn)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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