adsazad/bloker-block
Laravel package for managing and blocking unwanted requests or users, with simple configuration and middleware-style integration to enforce access rules across routes. Helps reduce abuse and control traffic with customizable blocking logic.
Installation:
composer require adsazad/bloker-block
Publish the config file (if available) with:
php artisan vendor:publish --provider="Adsazad\BlokerBlock\BlokerBlockServiceProvider"
Basic Usage: The package appears to be a Laravel block system (likely for content management or modular layouts). Start by registering a block in your service provider:
use Adsazad\BlokerBlock\Facades\BlokerBlock;
BlokerBlock::register('my_block', function () {
return view('blocks.my_block');
});
First Use Case: Render a block in a view:
@bloker('my_block')
Or dynamically:
echo BlokerBlock::render('my_block');
Block Registration:
BlokerBlock::register('header', function () {
return view('blocks.header')->with(['title' => 'Welcome']);
});
Dynamic Block Rendering:
BlokerBlock::render('sidebar', ['items' => $items]);
@bloker('sidebar', ['items' => $items])
Conditional Blocks:
if (BlokerBlock::exists('footer')) {
echo BlokerBlock::render('footer');
}
Priority-Based Rendering:
BlokerBlock::register('high_priority', function () { /* ... */ }, 10);
AppServiceProvider@boot() for global availability.$this->partialMock(BlokerBlock::class, function ($mock) {
$mock->shouldReceive('render')->andReturn('<div>Mocked</div>');
});
No Config File:
Namespace Collisions:
BlokerBlock in multiple providers, ensure unique block names (e.g., admin.header vs. user.header).View Resolution:
resources/views/blocks/ directory exists and is auto-loaded.Facade vs. Helper:
BlokerBlock::render() and @bloker directives equally. Test both in your project.try {
BlokerBlock::register('error_prone', function () { /* ... */ });
} catch (\Exception $e) {
Log::error("Block registration failed: " . $e->getMessage());
}
Adsazad\BlokerBlock\BlokerBlockManager).public function handle($request, Closure $next) {
if (!$request->user()->isAdmin()) {
BlokerBlock::forget('admin_panel');
}
return $next($request);
}
resources/views/blocks/_base.blade.php) and extend it.priority, context) as closure parameters or in a separate array:
BlokerBlock::register('dynamic_block', function () { /* ... */ }, [
'priority' => 5,
'context' => 'sidebar'
]);
How can I help you explore Laravel packages today?