Installation
composer require mralirezaeb/bugloos-test
Add to config/app.php under providers:
MrAlirezaEB\Bugloos\BugloosServiceProvider::class,
Publish Config
php artisan vendor:publish --provider="MrAlirezaEB\Bugloos\BugloosServiceProvider" --tag="config"
Configure config/bugloos.php (default values provided).
First Use Case Generate a dynamic paginated list in a controller:
use MrAlirezaEB\Bugloos\Facades\Bugloos;
public function index()
{
$list = Bugloos::make('posts')
->paginate(10)
->orderBy('created_at', 'desc')
->get();
return view('posts.index', compact('list'));
}
Blade Integration
Use the @bugloos directive in views:
@bugloos('posts', ['paginate' => 10, 'orderBy' => 'created_at desc'])
Dynamic List Generation
// Basic usage
$dynamicList = Bugloos::make('users')
->where('active', true)
->paginate(15)
->with(['posts' => function($query) {
$query->where('published', true);
}]);
// Chaining methods
Bugloos::make('products')
->search('query')
->filter(['category' => 'electronics'])
->sort('price', 'asc')
->limit(20);
API Integration
// Fetch from external API
Bugloos::make('external_data')
->fromApi('https://api.example.com/data')
->transform(function($item) {
return collect($item)->only(['id', 'name', 'value']);
});
Caching Strategies
// Cache for 5 minutes
Bugloos::make('recent_posts')
->cache(5)
->get();
// Cache with custom key
Bugloos::make('featured_products')
->cache(10, 'featured_products_cache_key');
View Composition
// Pass to view with metadata
$data = Bugloos::make('articles')
->paginate(8)
->withMetadata()
->get();
return view('articles.index', $data);
Bugloos::make(new App\Models\Post) for model-specific lists.Bugloos::make('comments')
->livewire()
->paginate(5);
$this->mock(Bugloos::class)->shouldReceive('make')->andReturnSelf();
Over-Eager Loading
with() without limits.->with(['comments' => function($query) {
$query->limit(3);
}])
Cache Invalidation
cacheFor() with versioned keys or implement manual invalidation:
Bugloos::make('posts')->cacheFor(30, 'posts_v' . $lastUpdatedAt);
API Rate Limits
->fromApi('url')->retry(3, 1000);
Pagination Conflicts
->paginate(10, 'custom_driver');
'debug' => env('BUGLOOS_DEBUG', false),
->debug() to dump the query builder:
Bugloos::make('users')->debug()->get();
Custom Query Builders Override the default query builder in config:
'query_builder' => MrAlirezaEB\Bugloos\QueryBuilders\CustomQueryBuilder::class,
Macros Extend functionality via facade macros:
Bugloos::macro('customMethod', function() {
return $this->where('status', 'active')->orderBy('priority');
});
Event Hooks Listen for list generation events:
Bugloos::listen('beforeGenerate', function($query, $listName) {
// Modify query or log
});
Service Provider Overrides
Bind custom implementations in AppServiceProvider:
$this->app->bind('bugloos', function($app) {
return new CustomBugloosManager();
});
How can I help you explore Laravel packages today?