- Can I use symfony/ux-map in a Laravel project without Symfony?
- No, symfony/ux-map requires Symfony UX 3.x, which isn’t natively compatible with Laravel. You’d need the Symfony Bridge (v7.4+) and adopt Symfony UX conventions like Stimulus controllers. Alternatively, use standalone Leaflet.js, but you’ll lose server-driven map configurations and reactivity.
- What Laravel versions support symfony/ux-map via Symfony Bridge?
- Laravel projects using the Symfony Bridge must align with Symfony 7.4+ and Symfony UX 3.x. There’s no direct Laravel version lock—compatibility depends on your Bridge setup and Stimulus/UX adoption. Test with Laravel 10.x+ for best results.
- How do I configure Leaflet.js providers (e.g., Mapbox, OpenStreetMap) in symfony/ux-map?
- Use Twig’s `ux_map()` function or `<twig:ux:map>` component to define providers. For Mapbox, include your access token in the `provider` option (e.g., `provider: 'mapbox://...'`). OpenStreetMap is pre-configured via `provider: 'osm'`. Custom providers require extending the `MapRenderer` class.
- Will symfony/ux-map work with my existing PostGIS database in Laravel?
- Yes, symfony/ux-map is backend-agnostic. If your Laravel app uses PostGIS (via spatie/laravel-postgis or similar), you can fetch geospatial data normally and pass it to Twig for map rendering. No additional setup is needed for PostGIS queries.
- What’s the migration path from Symfony UX 2.x to 3.x for symfony/ux-map?
- Symfony UX 3.x introduces breaking changes, like updated Stimulus controller syntax and Live Component APIs. Replace deprecated `render_map()` with `ux_map()` in Twig, and update Stimulus imports (e.g., `@symfony/ux-map` instead of older paths). Test thoroughly—some custom controllers may need refactoring.
- Can I use Google Maps API with symfony/ux-map instead of Leaflet?
- Yes, but you’ll need to create a custom `MapRenderer` extending `AbstractMapRenderer` and configure it for Google Maps. Leaflet is the default and recommended provider, but Google Maps is supported via the `provider` option in Twig. Note: This requires a Google Maps API key and may incur costs.
- How do I handle dynamic markers or real-time updates in symfony/ux-map?
- Use Symfony UX’s Live Components to update markers dynamically. Pass data via Twig’s `ux_map()` attributes (e.g., `markers: {{ dump(app.data) }}`) and leverage Stimulus actions to trigger updates. For real-time features, combine with Laravel Echo or Mercure for server pushes.
- Are there performance concerns with symfony/ux-map in production?
- Leaflet.js is lightweight, but complex maps (e.g., thousands of markers) may impact performance. Optimize by using clustering (via Leaflet.markercluster) or lazy-loading tiles. Enable Symfony’s asset mapper for production to minify JS/CSS. Monitor bundle sizes if using multiple UX components.
- What alternatives exist for interactive maps in Laravel if symfony/ux-map isn’t ideal?
- For Laravel-only projects, consider: **Leaflet.js standalone** (manual JS integration), **Mapbox GL JS** (for advanced maps), or Laravel-specific packages like `spatie/laravel-geo`. If you need Symfony UX features, **symfony/ux-map** is the most integrated option, but standalone libraries offer more flexibility.
- How do I debug Stimulus/UX issues with symfony/ux-map in Laravel?
- Enable Symfony’s Stimulus debug mode in your Bridge config and check browser console logs for errors. Use `stimulus:debug` in Twig to inspect registered controllers. For Laravel, ensure the Symfony Bridge’s asset pipeline is correctly configured. Common issues include missing Stimulus imports or Twig syntax errors in map components.