Install the Package
composer require akuma/distribution-bundle
Extend AkumaKernel
Replace your AppKernel (or Kernel in Symfony 4+) with:
// app/Kernel.php (Symfony 4+) or app/AppKernel.php (Symfony 3/2)
class AppKernel extends AkumaKernel
{
public function registerBundles()
{
$bundles = parent::registerBundles(); // Load Akuma-registered bundles first
$bundles[] = new Symfony\Bundle\FrameworkBundle\FrameworkBundle(); // Add your core bundles
return $bundles;
}
}
Define a Bundle for Auto-Registration
Create Resources/config/bundle.yml in your bundle (e.g., Acme/TestBundle):
bundle:
class: 'Acme\Bundle\TestBundle\AcmeTestBundle'
priority: 10 # Higher = loaded later
kernel: false # Set `true` if constructor requires Kernel
environment: ['dev', 'prod']
require: [] # Optional dependencies
Verify Registration Run the debug command:
php bin/console akuma:debug:bundle
Expected output: Your bundle listed under registered bundles.
Use this to load optional or environment-specific bundles without modifying AppKernel directly. Example:
DebugBundle only in dev environment.Bundle Registration
bundle.yml in every bundle you want auto-registered.priority to control load order (e.g., -10 for core dependencies, 10 for optional features).kernel: true if the bundle’s constructor requires Kernel (e.g., for container-aware services).Dependency Management
require to declare bundle dependencies (Akuma will load them first).require:
- { class: 'Acme\Bundle\AuthBundle\AuthBundle', kernel: true }
Environment-Specific Loading
environment:
environment: ['prod', 'staging'] # Skipped in 'dev'
Symfony 4+ Compatibility
getBundles() in Kernel.php:
public function getBundles()
{
return array_merge(parent::getBundles(), [
// Manually add non-Akuma bundles here
]);
}
Debugging Registration
akuma:debug:bundle to inspect loaded bundles and their metadata.bundle.yml class matches the actual bundle class name.priority values load first. Use negative numbers for core bundles.require cycles. Test thoroughly.bundle.yml in config/packages/your_bundle.yml (custom location).Kernel Constructor Issues
kernel: true is set but the bundle’s constructor doesn’t accept Kernel, Akuma will fail silently. Always verify constructors.use Symfony\Component\HttpKernel\KernelInterface; and update the constructor.Environment Mismatches
environment: ['prod'] won’t load in dev. Check with akuma:debug:bundle --env=prod.Priority Overrides
registerBundles(). If you override the entire method, you’ll lose Akuma’s auto-registration.array_merge or + operator:
return array_merge(parent::registerBundles(), [$yourBundle]);
Missing bundle.yml
bundle.yml won’t be auto-registered. Verify file paths (case-sensitive on Linux).Symfony 4+ Kernel Overrides
AppKernel is replaced with Kernel. Ensure your Kernel extends AkumaKernel and overrides getBundles() correctly.akuma:debug:bundle --env=prod --verbose to see raw bundle metadata.APP_DEBUG=1) to catch constructor failures.extends AkumaKernel to isolate issues.Custom Bundle Loaders
Akuma\Bundle\DistributionBundle\Loader\BundleLoader to add logic (e.g., load bundles from a database).Dynamic Configuration
AkumaKernel::getBundleConfig() to fetch bundle.yml from a remote source (e.g., API).Event Listeners
akuma.bundle.register (dispatches after bundle loading) to modify bundles post-registration:
$eventDispatcher->addListener('akuma.bundle.register', function ($event) {
$event->getBundles()[] = new YourDynamicBundle();
});
Priority Adjustment
priority via config or environment variables:
# config/packages/akuma.yml
akuma:
priority_adjustment: 5 # Adds 5 to all bundle priorities
How can I help you explore Laravel packages today?