Installation Add the package via Composer:
composer require bungle-suit/framework-bundle
Publish the bundle's configuration (if applicable):
php artisan vendor:publish --provider="Bungle\Bundle\FrameworkBundle\FrameworkBundleServiceProvider"
First Use Case
Register the service provider in config/app.php under providers:
Bungle\FrameworkBundle\FrameworkBundleServiceProvider::class,
Initial Configuration
Check config/framework.php (auto-generated if published) for core settings like:
Basic Usage Trigger the framework's core functionality (e.g., bootstrapping) via:
use Bungle\FrameworkBundle\Facades\Framework;
// Example: Register a custom route group
Framework::routeGroup(['prefix' => 'api/v1'], function () {
// Routes here
});
Middleware Integration Extend Laravel's middleware stack by binding Bungle-specific middleware:
// In a service provider
$this->app->extend('middleware', function ($middleware) {
return array_merge($middleware, [
\Bungle\FrameworkBundle\Http\Middleware\Authenticate::class,
]);
});
Service Binding Bind custom services to the container:
$this->app->singleton('bungle.logger', function () {
return new \Bungle\FrameworkBundle\Services\LoggerService();
});
Route Grouping Use Bungle's route grouping for modularity:
Framework::routeGroup(['namespace' => 'App\Http\Controllers\Admin'], function () {
Route::get('/dashboard', 'DashboardController@index');
});
Event Listeners
Subscribe to Bungle events (e.g., FrameworkInitialized):
event(new \Bungle\FrameworkBundle\Events\FrameworkInitialized());
Framework::asset('js/app.js')->version('1.0.0');
Resource class for API responses:
class UserResource extends \Bungle\FrameworkBundle\Http\Resources\Resource
{
public function toArray($request)
{
return ['name' => $this->resource->name];
}
}
$this->app->instance('bungle.logger', Mockery::mock());
Configuration Overrides
config/framework.php directly; use environment variables or the config() helper:
config(['framework.default_locale' => env('APP_LOCALE', 'en')]);
php artisan config:clear
Middleware Conflicts
unless/only guards:
Route::middleware(['bungle.auth', 'web'])->group(...);
Service Provider Boot Order
FrameworkBundleServiceProvider loads after Laravel's core providers (e.g., RouteServiceProvider):
// In app.php
'providers' => [
// Laravel providers...
Bungle\FrameworkBundle\FrameworkBundleServiceProvider::class,
],
Deprecated Methods
@deprecated tags in the source. Example:
// Avoid this (deprecated)
Framework::oldMethod();
// Use instead:
Framework::newMethod();
config(['framework.debug' => true]);
php artisan route:list --bungle
dd(app()->getBindings());
Custom Directives
Extend Blade directives via Bungle's Directive class:
Framework::directive('bungleDirective', function ($expression) {
return "<?php echo Bungle\\Helpers::process({$expression}); ?>";
});
Hooks
Use Bungle's Framework::hook() to tap into lifecycle events:
Framework::hook('beforeBoot', function () {
// Run code before framework boots
});
Asset Pipeline Override default asset paths:
Framework::asset('css/app.css')->setPath(public_path('custom/css/app.css'));
Testing Helpers Use Bungle's testing traits:
use Bungle\FrameworkBundle\Testing\TestCase;
class MyTest extends TestCase
{
public function testSomething()
{
$this->actingAsBungleUser();
// ...
}
}
How can I help you explore Laravel packages today?