Installation Add the package via Composer:
composer require laravel/facade-documenter --dev
Register the service provider in config/app.php under providers (if not auto-discovered):
Laravel\FacadeDocumenter\ServiceProvider::class,
First Use Case Run the facades:document command to generate docblocks for all Laravel facades in your project:
php artisan facades:document
This will create/update app/Facades/ with documented facade stubs.
Where to Look First
app/Facades/ directory for updated stubs.config/facade-documenter.php for customization options.src/Documenter.php for core logic if extending functionality.Generating Facade Stubs
php artisan facades:document to update all facades.config/facade-documenter.php:
'exclude' => [
'Auth',
'Cache',
],
Customizing Docblock Format
Modify the template in resources/views/vendor/facade-documenter/facade.blade.php to adjust docblock structure, e.g., adding @throws or @method tags.
Integrating with IDE
app/Facades/ (IDE-aware path).php artisan facades:document in your CI/CD pipeline to keep stubs updated.Workflow Integration
composer.json to auto-generate stubs:
"scripts": {
"post-update-cmd": "php artisan facades:document"
}
Testing Facades Use the generated stubs in tests to avoid runtime dependency issues:
use App\Facades\AuthFacade; // Auto-complete works here
Stub Overwrites
app/Facades/ may be overwritten on re-generation. Commit them to avoid surprises.php artisan facades:document --force to skip existing files (not recommended for production).Dynamic Facades
Facade::method($param)) may not document correctly. Exclude or manually stub these.IDE Caching
Namespace Conflicts
app/Facades/ is in your autoload path (composer.json). Add if missing:
"autoload": {
"psr-4": {
"App\\Facades\\": "app/Facades/"
}
}
Auth::attempt() relies on Illuminate\Auth\AuthManager).resources/views/vendor/facade-documenter/ for syntax issues.--verbose for debug output:
php artisan facades:document --verbose
Partial Updates
Use --facade to update a single facade:
php artisan facades:document --facade=Auth
Custom Templates Override the default template by publishing it:
php artisan vendor:publish --tag=facade-documenter-views
Exclude Non-Laravel Facades
Filter out third-party facades by adjusting the config/facade-documenter.php:
'facades' => [
'Illuminate\\*',
'App\\Facades\\*',
],
CI/CD Optimization Skip docblock generation in CI if stubs are committed:
if [ "$CI" != "true" ]; then php artisan facades:document; fi
Legacy Facades For facades not auto-detected, manually add their class paths to the config:
'facades' => [
'App\\Facades\\CustomFacade' => 'App\\Services\\CustomService',
],
How can I help you explore Laravel packages today?