becklyn/rad-bundles
Lightweight helpers for Symfony bundles/apps: includes BundleExtensions and ConfigurableBundleExtension to simplify bootstrapping, configuration loading, and extension setup. Useful starting point for building bundles with a consistent, minimal structure.
Installation
composer require becklyn/rad-bundles
No additional configuration is required—it’s a lightweight utility package.
First Use Case Check if a bundle is enabled in your Symfony/Laravel app (if using Symfony’s kernel):
use Becklyn\RadBundles\BundleChecker;
$isEnabled = BundleChecker::isEnabled('FrameworkBundle');
Where to Look First
BundleChecker class: Core utility for bundle operations.BundleLoader class: For loading bundles dynamically.BundleCollection class: Manage collections of bundles.Bundle Activation/Deactivation Dynamically enable/disable bundles at runtime (useful for feature flags or modular apps):
BundleChecker::enable('AcmeDemoBundle');
BundleChecker::disable('AcmeDemoBundle');
Bundle Dependency Management Validate bundle dependencies before loading:
$dependencies = BundleChecker::getDependencies('AcmeDemoBundle');
foreach ($dependencies as $dep) {
if (!BundleChecker::isEnabled($dep)) {
throw new \RuntimeException("Missing dependency: {$dep}");
}
}
Lazy-Loading Bundles Load bundles only when needed (e.g., for plugins or optional features):
$bundleLoader = new BundleLoader();
$bundle = $bundleLoader->load('AcmeLazyBundle', __DIR__.'/vendor');
Bundle Collections Group related bundles for batch operations:
$collection = new BundleCollection(['AcmeBundle1', 'AcmeBundle2']);
$collection->enableAll();
Symfony Kernel Integration
If using Symfony, extend the kernel to leverage BundleChecker in boot() or shutdown():
public function boot()
{
if (BundleChecker::isEnabled('AcmeDebugBundle')) {
$this->registerDebugToolbar();
}
}
Laravel Adaptation For Laravel (non-Symfony), use the package to manage "bundles" as standalone modules:
// Pseudocode: Treat Laravel packages as "bundles"
if (BundleChecker::isEnabled('AcmeAnalytics')) {
$this->loadAnalyticsService();
}
Event-Driven Workflows Trigger actions when bundles are enabled/disabled:
BundleChecker::onEnable('AcmeBundle', function () {
Log::info('AcmeBundle enabled!');
});
Symfony-Specific Assumptions
Bundle classes extending Bundle). In Laravel, you’ll need to adapt the logic (e.g., treat packages as "bundles").BundleChecker::isEnabled() to check Laravel’s config('app.enabled_packages') or similar.Circular Dependencies
BundleChecker::getDependencies() may not handle circular dependencies gracefully.symfony/dependency-injection.Namespace Collisions
AcmeBundle vs. Acme\Bundle), the package may misidentify them.Acme\Bundle\DemoBundle).Performance Overhead
BundleChecker::getAll()) can be slow in large apps.Verify Bundle Paths
Use BundleLoader::findBundle() to debug missing bundles:
$path = BundleLoader::findBundle('AcmeBundle');
if (!$path) {
throw new \RuntimeException("Bundle not found!");
}
Enable Verbose Logging
Temporarily enable debug mode in BundleChecker:
BundleChecker::setDebug(true);
Custom Bundle Resolvers
Extend BundleLoader to support non-standard bundle formats:
class CustomBundleLoader extends BundleLoader {
public function loadCustomBundle(string $name): object {
// Custom logic here
}
}
Hook into Bundle Lifecycle
Override BundleChecker::onEnable()/onDisable() to add custom logic:
BundleChecker::onEnable('AcmeBundle', function () {
// Post-enable logic
});
Add Bundle Metadata Extend the package to support custom metadata (e.g., version, author):
BundleChecker::addMetadata('AcmeBundle', ['version' => '1.0.0']);
bundles_path:
BundleLoader::setBundlesPath(__DIR__.'/custom_bundles');
How can I help you explore Laravel packages today?