elasticms/common-bundle
Shared library bundle for elasticMS, used by the Core and Client Helper bundles. Provides common code, utilities, and services to keep the platform consistent. Documentation available on the EMS project site; issues and PRs via the elasticMS monorepo.
elasticms/common-bundle is a shared utility layer designed for the EMS ecosystem, likely containing domain-agnostic helpers (e.g., validation, logging, DTOs, or event-driven workflows). It aligns well with Laravel applications requiring cross-cutting concerns (e.g., multi-tenancy, API standardization) but lacks Laravel-native abstractions (e.g., Eloquent, Blade).HttpFoundation, EventDispatcher) introduces friction. Laravel’s illuminate/support provides partial compatibility, but custom adapters may be needed for:
ContainerInterface vs. Laravel’s Container.EventDispatcher vs. Laravel’s Events facade.Symfony\Component\HttpFoundation\Request vs. Illuminate\Http\Request.Content, Media) map to your Laravel app’s needs. For example:
symfony/http-client, symfony/options-resolver) conflicting with Laravel’s versions. Mitigate with:
composer require elasticms/common-bundle --with-all-dependencies.// composer.json
"conflict": {
"symfony/http-client": "dev-main" // Force Laravel-compatible version
}
config/packages/. Laravel requires custom config files (e.g., config/elasticms.php). Use a service provider to merge configurations:
// ElasticmsServiceProvider.php
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/elasticms.php', 'elasticms');
}
EventDispatcher differs from Laravel’s Events. Create a bridge:
// app/Providers/EventBridgeServiceProvider.php
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyDispatcher;
use Illuminate\Support\Facades\Event;
public function boot()
{
$symfonyDispatcher = new SymfonyDispatcher();
Event::listen(function ($event) use ($symfonyDispatcher) {
$symfonyDispatcher->dispatch($event->getName(), $event);
});
}
intl, gd), specific Symfony versions.phpstan, psalm) and unit tests for core components.php artisan debug:container # Check service overhead
parameters.yaml.spatie/laravel-medialibrary) sufficient?autowiring vs. Laravel’s bind())EventDispatcher vs. Laravel’s Events)spatie/laravel-package-tools, laravelista/laravel-modules.illuminate/support) for:
Symfony\Component\HttpFoundation\Request ↔ Illuminate\Http\Request.Symfony\Component\Console ↔ Illuminate\Console.// app/Providers/EventBridgeServiceProvider.php
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyDispatcher;
public function register()
{
$symfonyDispatcher = new SymfonyDispatcher();
$this->app->singleton('symfony.event_dispatcher', fn() => $symfonyDispatcher);
// Listen to Laravel events and dispatch to Symfony
Event::listen('*', function ($event) use ($symfonyDispatcher) {
$symfonyDispatcher->dispatch($event->getName(), $event);
});
}
Symfony\Component\EventDispatcher with Illuminate\Events\Dispatcher.replace to force Laravel-compatible versions:
"replace": {
"symfony/http-client": "1.0.0|dev-main"
}
Phase 1: Proof of Concept (PoC)
composer require elasticms/common-bundle
app('ems.common.service').event(new \EMS\CommonBundle\Event\CustomEvent()).config('elasticms.services.timeout').Phase 2: Incremental Adoption
EMS\CommonBundle\Logger\TenantLogger.if (config('app.enable_ems_bundle')) {
$service = app('ems.common.service');
}
Phase 3: Full Integration
// config/elasticms.php
return [
'services' => [
'timeout' => env('EMS_TIMEOUT', 30),
],
];
Route objects).| Symfony Feature | Laravel Equivalent | Integration Strategy |
|---|---|---|
Symfony\Component\HttpFoundation\Request |
Illuminate\Http\Request |
Use Laravel’s Request facade; wrap Symfony calls. |
Symfony\Component\EventDispatcher |
Illuminate\Events\Dispatcher |
Create a bridge service provider. |
Symfony\Component\Console\Command |
Illuminate\Console\Command |
Extend Laravel’s Command class. |
Symfony\Component\DependencyInjection\Container |
Illuminate\Container\Container |
Use Laravel’s container; avoid direct Symfony DI. |
Symfony\Component\Config\Loader\LoaderInterface |
Illuminate\Config\Repository |
Merge YAML config into Laravel’s PHP arrays. |
Symfony\Component\Routing\RequestContext |
Illuminate\Routing\Router |
Use Laravel’s router; avoid Symfony routing. |
How can I help you explore Laravel packages today?