arielmejiadev / leaflet-for-laravel
brings an easy integration to use leaflet javascript library using Laravel with blade views
Package info
github.com/ArielMejiaDev/leaflet-for-laravel
pkg:composer/arielmejiadev/leaflet-for-laravel
Fund package maintenance!
Requires
- php: ^8.3
- illuminate/contracts: ^11.0||^12.0||^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^11.0.0||^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.39
This package is auto-updated.
Last update: 2026-05-22 19:04:04 UTC
README
A fluent, expressive PHP API for rendering Leaflet.js maps in Laravel — no JavaScript required.
Quick Start
1. Install
composer require arielmejiadev/leaflet-for-laravel
2. Build a map in your controller
use arielmejiadev\LeafletForLaravel\LeafletMap; use arielmejiadev\LeafletForLaravel\Marker; class LandmarkController extends Controller { public function index() { $map = LeafletMap::of('landmarks') ->center(40.6892, -74.0445) ->zoom(15) ->marker(40.6892, -74.0445, fn (Marker $pin) => $pin ->popup('<b>Statue of Liberty</b><br>New York, NY') ->icon('blue') ); return view('landmarks.index', compact('map')); } }
3. Render in Blade
<!DOCTYPE html> <html> <head> @leafletStyles </head> <body> @leafletMap($map) </body> </html>
That's it — two Blade directives and you have a live, interactive map.
Features
- Pure PHP — write maps in PHP, zero JavaScript needed
- Fluent API — chainable methods like
->center()->zoom()->marker() - Markers — popups, tooltips, draggable pins, colored icons, circles
- Glyph Icons — Font Awesome & Material Design icons rendered on pins
- Layer Control — multiple base map styles + toggleable overlay groups
- GeoJSON — render points, lines, and feature collections
- Blade Directives —
@leafletStyles+@leafletMap($map) - Livewire Ready — scaffold components with
php artisan make:leaflet - Macros & Conditionals — extend with
Map::macro(), branch with->when() - Multiple Maps — independent instances on the same page
Installation
composer require arielmejiadev/leaflet-for-laravel
Optionally publish the config:
php artisan vendor:publish --tag="leaflet-for-laravel-config"
Documentation
Visit the full documentation site for guides on:
- Maps — center, zoom, dimensions, tile layers, macros
- Markers — popups, tooltips, icons, circles, bulk markers
- Icons — colors, custom icons, Font Awesome & Material Design glyphs
- Layer Control — base map switching, overlay groups
- GeoJSON — points, lines, files, APIs
- Advanced Example — full controller with everything combined
- Artisan Command — generate PHP or Livewire map classes
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.