Installation
composer require ekyna/resource-bundle
(Note: As of writing, the README lacks installation instructions—verify composer.json for exact requirements.)
Basic Usage
Register the service provider in config/app.php under providers:
Ekyna\ResourceBundle\ResourceBundleServiceProvider::class,
First Use Case Load a resource bundle via a facade (if provided) or service container:
$bundle = app('resource-bundle')->load('path/to/bundle');
(Check for a ResourceBundle facade or helper methods in the package.)
Locate Documentation
src/ directory for core classes (e.g., ResourceBundleManager, BundleLoader).tests/ for usage examples.Bundle Registration
Define bundles in config/resource-bundle.php (if auto-generated):
'bundles' => [
'admin' => [
'path' => resource_path('bundles/admin'),
'namespace' => 'Admin\\',
],
],
Dynamic Loading Load bundles programmatically:
$bundle = app('resource-bundle')->get('admin');
$translations = $bundle->get('messages.welcome');
Integration with Laravel Features
@inject('bundle', 'Ekyna\ResourceBundle\ResourceBundle')
{{ $bundle->get('admin')->get('title') }}
return response()->json(['title' => $bundle->get('admin')->get('title')]);
Custom Bundle Types
Extend Ekyna\ResourceBundle\Contracts\BundleInterface for non-standard formats (e.g., JSON, YAML):
class CustomBundle implements BundleInterface {
public function get($key) { ... }
}
trans() with bundle-aware calls.config/bundles/settings.php).Missing Installation Docs
TODO in README.md suggests incomplete setup. Verify:
config/resource-bundle.php).Namespace Collisions
'bundles' => [
'vendor.prefix.admin' => [...],
],
Caching Quirks
php artisan config:clear
Bundle Not Found? Check if the bundle path exists and is registered in config. Enable debug mode:
app('resource-bundle')->setDebug(true);
Key Not Resolving?
Verify the bundle’s structure matches the key path (e.g., messages.welcome → messages/welcome.php).
Custom Loaders
Implement Ekyna\ResourceBundle\Contracts\LoaderInterface for non-file sources (e.g., database):
class DatabaseLoader implements LoaderInterface {
public function load($bundleName) { ... }
}
Event Hooks Listen for bundle events (if the package supports them):
event(new BundleLoaded('admin'));
Testing Mock bundles in tests:
$this->app->instance('resource-bundle', MockBundle::class);
$bundles = app('resource-bundle')->discover(resource_path('bundles/*'));
'fallbacks' => ['admin' => ['default']],
How can I help you explore Laravel packages today?