afrihost/base-command-bundle
Symfony bundle providing an opinionated base class for console commands to reduce boilerplate. Adds built-in initialization for common needs like logging and locking, with global defaults via config and per-command or runtime overrides for flexible behavior.
ContainerAwareCommand), but Laravel’s Artisan commands (which extend Illuminate\Console\Command) are structurally similar. A Laravel TPM could leverage this by:
Illuminate\Container\Container).ContainerAwareCommand as inspiration for a Laravel-specific base command class (e.g., BaseCommand with shared logging/locking logic).Log::channel()).terminating, starting).bindCommand() or extend() methods.LoggerInterface with Laravel’s Psr\Log\LoggerInterface (already compatible).Symfony\Component\Lock\LockFactory to Laravel’s Illuminate\Cache\Lock or a custom solution.config(['command.key' => value])).LockFactory: Requires a Laravel-compatible alternative (e.g., redis-lock or laravel-lock).ContainerAwareCommand injects the container via getContainer(). Laravel’s Command uses app() or constructor injection.Symfony\Component\Console\Input\InputInterface is identical in Laravel, but some methods (e.g., getHelperSet()) may need adapters.| Risk Area | Severity | Mitigation |
|---|---|---|
| Container Incompatibility | High | Abstract container access behind an interface (e.g., ContainerAware). |
| Locking Mechanism | Medium | Use Laravel’s Illuminate\Cache\Lock or a polyfill for LockFactory. |
| Logging Channel Mismatch | Low | Wrap Symfony’s logger in Laravel’s Log facade or use a bridge package. |
| Deprecated Symfony APIs | Low | Check for Symfony 5+ compatibility; Laravel 9+ uses Symfony 5.4 components. |
| Testing Overhead | Medium | Write Laravel-specific tests for adapted methods (e.g., handle() lifecycle). |
spatie/laravel-lock instead.bindCommand() or manually? Does the bundle support Laravel’s CommandServiceProvider?laravel-zero/framework (for CLI apps).App\Console\Commands\BaseCommand with shared traits.ContainerAwareCommand can be mapped to Laravel’s Illuminate\Console\Command with minimal changes.getContainer() with Laravel’s app() or constructor injection.Log facade or a PSR-3 bridge (e.g., monolog/laravel).Symfony\Component\Lock\LockFactory with:
Illuminate\Cache\Lock (file/redis driver).spatie/laravel-lock for distributed locks.config() helper or runtime overrides via config(['command.key' => value]).BaseCommand class to Laravel:
ContainerAwareCommand with Illuminate\Console\Command.LoggerInterface with Psr\Log\LoggerInterface (Laravel-compatible).LockFactory with a Laravel-compatible alternative.laravel-base-command) with:
BaseCommand abstract class.config() (e.g., config/command.php).--log-level=debug flags).| Feature | Symfony Bundle | Laravel Adaptation | Notes |
|---|---|---|---|
| Container Access | getContainer() |
app() or constructor injection |
Use Laravel’s DI best practices. |
| Logging | LoggerInterface |
Psr\Log\LoggerInterface (Laravel’s Log) |
Works out-of-the-box. |
| Locking | LockFactory |
Illuminate\Cache\Lock or spatie/laravel-lock |
Requires adapter layer. |
| Runtime Config Overrides | CLI args | Artisan flags (e.g., --log-level) |
Use Laravel’s Input binding. |
| Configuration | Symfony config/ |
Laravel config() or published config file |
Leverage Laravel’s config caching. |
handle() lifecycle).Log facade.app() forHow can I help you explore Laravel packages today?