Installation Add the bundle via Composer (note: package is outdated; verify compatibility with your Laravel version):
composer require antwebes/help-bundle
Register the bundle in config/app.php under providers (if using Symfony-style bundles) or manually bootstrap in bootstrap/app.php (if adapted for Laravel).
Configuration Publish the bundle’s config (if available) via:
php artisan vendor:publish --provider="Antwebes\HelpBundle\HelpBundle"
Check config/help.php for default settings (e.g., help storage paths, default templates).
First Use Case Display help content for a route/controller:
// In a controller or Blade template
use Antwebes\HelpBundle\HelpManager;
$helpManager = app(HelpManager::class);
$helpContent = $helpManager->getHelp('dashboard'); // 'dashboard' = route/controller name
return view('dashboard', ['help' => $helpContent]);
Render in Blade:
@if($help)
<div class="help-content">{{ $help }}</div>
@endif
Help Content Management
resources/help/dashboard.yml).
Example dashboard.yml:
title: "Dashboard Overview"
content: "This section shows your analytics..."
Integration with Routes/Controllers
// app/Http/Middleware/AttachHelpMiddleware.php
public function handle($request, Closure $next) {
$help = app(HelpManager::class)->getHelp($request->route()->getName());
$request->merge(['help' => $help]);
return $next($request);
}
public function __construct(private HelpManager $helpManager) {}
public function show() {
$help = $this->helpManager->getHelp('user.profile');
return view('profile', compact('help'));
}
Template Patterns
@component('help::partial', ['content' => $help->content])
@endcomponent
@auth
@if(auth()->user()->isAdmin())
{{ $help }}
@endif
@endauth
Localization
resources/help/en/dashboard.yml, resources/help/fr/dashboard.yml).$help = $helpManager->getHelp('dashboard', app()->getLocale());
Outdated Package
HelpManager) as a standalone Laravel package.No Built-in Storage
resources/help/. For dynamic content, you’ll need to:
Antwebes\HelpBundle\Storage\FileStorage to use Eloquent.Route Naming Assumptions
user.create vs. user.create.index) will return null.HelpManager:
$routeName = Str::slug($request->route()->getName());
No Caching Layer
$help = Cache::remember("help_{$routeName}", now()->addHours(1), function() use ($routeName) {
return $this->helpManager->getHelp($routeName);
});
resources/help/ (case-sensitive).dashboard route → dashboard.yml).storage/ and resources/ to 755).yaml-lint or jsonlint.com).Custom Storage
Implement Antwebes\HelpBundle\Storage\StorageInterface:
class DatabaseStorage implements StorageInterface {
public function getHelp(string $key): ?string {
return HelpModel::where('key', $key)->value('content');
}
}
Bind it in config/help.php:
'storage' => \App\Services\DatabaseStorage::class,
Help Events Listen for help retrieval events (if the bundle supports them) or create your own:
event(new HelpRetrieved($routeName, $helpContent));
Blade Directives
Add a @help directive for concise templates:
// app/Providers/BladeServiceProvider.php
Blade::directive('help', function ($routeName) {
return "<?php echo app(\Antwebes\HelpBundle\HelpManager::class)->getHelp({$routeName}); ?>";
});
Usage:
@help('dashboard')
API Integration Expose helps via API routes:
Route::get('/help/{key}', function ($key) {
return response()->json(['help' => app(HelpManager::class)->getHelp($key)]);
});
How can I help you explore Laravel packages today?