Installation
Add the bundle to your composer.json:
composer require edlcdmc/common-bundle
Register the bundle in config/app.php under ExtraBundles (if using Symfony/Laravel-Symfony hybrid) or manually bootstrap via composer.json autoload.
First Use Case
Check the src/Resources/config/services.yml for default configurations. If the bundle provides a service (e.g., common.service), bind it in Laravel’s config/services.php:
'common' => [
'default' => env('COMMON_SERVICE', 'common.service'),
],
Then resolve it in a controller:
use Illuminate\Support\Facades\Config;
$service = app()->make(Config::get('services.common.default'));
Where to Look First
src/: Core logic (services, utilities).Resources/config/: Default configurations (override via Laravel’s config/).README.md: Check for undocumented features (e.g., CLI commands, event listeners).Service Integration
If the bundle provides a CommonService, extend it or wrap it in a Laravel service provider:
// app/Providers/CommonServiceProvider.php
public function register()
{
$this->app->singleton('common', function ($app) {
return new \Edlcdmc\CommonBundle\Service\CommonService(
$app['config']['common.settings']
);
});
}
Configuration Overrides Publish and override default configs:
php artisan vendor:publish --provider="Edlcdmc\CommonBundle\CommonBundle"
Then customize config/common.php.
Event Listeners
If the bundle dispatches events (e.g., CommonEvent), listen in Laravel’s EventServiceProvider:
protected $listen = [
\Edlcdmc\CommonBundle\Event\CommonEvent::class => [
\App\Listeners\HandleCommonEvent::class,
],
];
CLI Commands
Register bundle commands in app/Console/Kernel.php:
protected $commands = [
\Edlcdmc\CommonBundle\Command\CommonCommand::class,
];
$container->get(); use app()->make()).// app/Providers/BladeServiceProvider.php
Blade::directive('commonHelper', function ($expr) {
return "<?php echo app('common')->{$expr}; ?>";
});
Namespace Collisions
The bundle may use Edlcdmc\CommonBundle\* namespaces. Ensure no conflicts with your app’s app/ namespace.
Symfony vs. Laravel Quirks
$service = $this->app->makeWith(\Edlcdmc\CommonBundle\Service\CommonService::class, [
'config' => $this->app['config']['common'],
]);
routes.php or use middleware to intercept.Configuration Merging
Laravel’s config() merges arrays recursively. If the bundle expects a flat config, use:
$config = array_merge(
require __DIR__.'/common.php',
$this->app['config']['common']
);
Zero Stars/Maturity
APP_DEBUG=true in .env to surface Symfony-style errors.\Log::debug('CommonBundle output', ['data' => $service->execute()]);
Custom Services Extend core services via traits or inheritance:
use Edlcdmc\CommonBundle\Service\CommonService as BaseService;
class ExtendedCommonService extends BaseService {
public function customMethod() { ... }
}
Event Decorators Decorate bundle events to add Laravel-specific logic:
$event->setUser(auth()->user()); // Inject Laravel auth
Command Extensions
Override bundle commands by re-registering them in app/Console/Kernel.php:
$this->commands = [
\App\Console\Commands\CustomCommonCommand::class,
];
How can I help you explore Laravel packages today?