cethyworks/google-map-display-bundle
AppKernel), but Laravel’s service container and Twig/Blade templating can adapt its core logic (command-based map injection). The bundle’s reliance on JavaScript API (not server-side rendering) reduces backend coupling.GoogleMapDisplayCommandHandler) to defer map initialization to the frontend, which is clean but requires client-side JS execution.AppKernel registration with Laravel’s service provider (register() method).config.yml with Laravel’s config/google_map_display.php.GoogleMapDisplayCommandHandler (via bind() or singleton()).<script> tags into the DOM. In Laravel, this could be handled via:
$maps data).@map('map_id', 'address')).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Deprecated Symfony | High | Abstract Symfony-specific logic (e.g., event dispatchers) into Laravel-compatible interfaces. |
| jQuery Dependency | Medium | Replace with vanilla JS or Laravel’s front-end stack (e.g., Alpine.js). |
| No Active Maintenance | High | Fork the repo to modernize (e.g., add TypeScript support, Laravel 10 compatibility). |
| API Key Hardcoding | Medium | Use Laravel’s .env and config() helper. |
| No Type Safety | Low | Add PHPDoc annotations or migrate to PHP 8+ typed properties. |
| Monolithic JS | Medium | Decouple map initialization into a separate JS module (e.g., using Laravel Mix). |
app()->bind() vs. bind())?laravel-google-maps instead?AppKernel.<script> tags).map_id ↔ address in a maps table)..env and config/google_map_display.php:
'google' => [
'api_key' => env('GOOGLE_MAPS_API_KEY'),
],
GoogleMapDisplayCommandHandler with a Laravel-compatible version:
// app/Providers/GoogleMapServiceProvider.php
public function register() {
$this->app->singleton(GoogleMapDisplayCommandHandler::class, function ($app) {
return new GoogleMapDisplayCommandHandler(
$app['config']['google_map_display.google.api_key']
);
});
}
// app/Facades/GoogleMap.php
public static function addMap(string $id, string $address) {
app(GoogleMapDisplayCommandHandler::class)->addMap($id, $address);
}
@googleMap('map-container', '1600 Amphitheatre Parkway, Mountain View')
// resources/js/google-maps.js
document.addEventListener('DOMContentLoaded', () => {
const script = document.createElement('script');
script.src = `https://maps.googleapis.com/maps/api/js?key=${GOOGLE_MAPS_API_KEY}`;
script.async = true;
script.defer = true;
document.head.appendChild(script);
});
dispatch() or Event facade.Maps JavaScript API enabled.UPGRADING.md..env).Log facade:
try {
$handler->addMap($id, $address);
} catch (\Exception $e) {
Log::error("Google Map failed for {$id}: {$e->getMessage()}");
}
cache()->remember()).client:map library for batch requests if displaying multiple maps.| Failure Scenario | Impact | Recovery Strategy |
|---|---|---|
| Google Maps API key invalid | Maps fail to load | Validate .env and check Google Cloud. |
| API quota exceeded | Maps degrade or fail | Upgrade plan or implement caching. |
| jQuery missing | JS errors | Replace with vanilla JS/Alpine.js. |
| Database corruption (if extended) | Stored addresses break | Use migrations and rollback tests. |
| Frontend JS bundle fails | All maps broken | Feature flag maps behind a JS check. |
@googleMap directive).How can I help you explore Laravel packages today?