InstallerInterface pattern. This fits well in monolithic Laravel apps or modular architectures (e.g., using Laravel Packages or Lumen) where post-installation hooks (e.g., database migrations, config generation, or asset setup) are needed.php artisan install:bundle), but lacks native event integration.BundleA installs before BundleB). Requires manual ordering or custom logic.InstallerInterface or Symfony components.symfony/console).InstallerInterface usage is required.Artisan commands + package service providers? If not, what unique value does it provide?spatie/laravel-package-tools or orchestra/platform for inspiration).post-install-cmd) or Laravel’s boot() methods?boot() methods for one-time setup.--force flags for idempotency.boot() or composer scripts.ekyna:install with:
// In BundleServiceProvider.php
public function boot()
{
$this->publishes([__DIR__.'/config/config.php' => config_path('bundle.php')]);
// Run migrations if needed
if (!Schema::hasTable('bundle_tables')) {
(new CreateBundleTables())->up();
}
}
InstallerInterface with a Laravel-specific trait:
trait LaravelInstaller
{
public function install(): void
{
// Use Laravel helpers (e.g., Schema, Config, Artisan)
}
}
Log facade.composer require symfony/console symfony/process --dev
mbstring, json, and fileinfo are enabled (common Laravel requirements).DB facade isn’t initialized. Add checks:
if (!app()->bound('db')) {
throw new \RuntimeException('Database not configured.');
}
composer.json constraints:
"require": {
"symfony/console": "3.4.*",
"symfony/dependency-injection": "3.4.*"
}
config/app.php:
'providers' => [
Ekyna\InstallBundle\EkynaInstallBundle::class,
],
php artisan vendor:publish --provider="Ekyna\InstallBundle\EkynaInstallBundle"
php artisan ekyna:install --bundle="Vendor\BundleName"
spatie/laravel-package-tools) for future-proofing.InstallerInterface implementations.use Illuminate\Support\Facades\Log;
public function install(): void
{
try {
// Install logic
} catch (\Throwable $e) {
Log::error("Installer failed: {$e->getMessage()}", ['bundle' => $this->getName()]);
throw $e;
}
}
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Installer throws uncaught exception | Silent failure; partial installation | Add global exception handling in the bundle. |
| Dependency conflicts | Composer install fails | Pin Symfony dependencies strictly. |
| Database connection issues | Installer hangs/fails | Retry logic with exponential backoff. |
| PHP version incompatibility | Runtime errors | Use Docker/PHP containers for isolation. |
| Race conditions (multi-user installs) | Corrupted state | Use Laravel’s Cache::lock() for synchronization. |
InstallerInterface implementations.boot() methods, Artisan commands) to reduce reliance on the bundle.php artisan install:validate
How can I help you explore Laravel packages today?