phpdocumentor/template-abstract
Abstract base template package for phpDocumentor. Provides common structure, assets, and utilities used by documentation templates, making it easier to build and maintain custom phpDocumentor themes with shared, reusable components.
Installation:
composer require phpdocumentor/template-abstract
Ensure phpdocumentor/phpdocumentor is also installed (this package is a template for phpDocumentor).
Basic Usage:
phpDocumentor to use this template in your phpdoc.dist.php or phpdoc.php:
return [
'template' => 'phpdocumentor/template-abstract',
// Other phpDocumentor config...
];
vendor/bin/phpdoc -d src -t docs
First Use Case: Generate API documentation for a Laravel project:
vendor/bin/phpdoc -d app/Http -t docs/api --title="My Laravel API Docs"
Output will be a clean, modern HTML template in the docs/api directory.
CI/CD Pipeline:
- name: Generate API Docs
run: vendor/bin/phpdoc -d src -t docs/api --template=phpdocumentor/template-abstract
gh-pages branch or deploy to a static host (e.g., Netlify).Laravel-Specific Use Cases:
/**
* @route GET /api/users
* @template-extends \phpDocumentor\Template\AbstractTemplate\RouteTemplate
*/
class UserController extends Controller { ... }
app/Services/UserService.php) with @method tags for clarity.Customization:
vendor/phpdocumentor/template-abstract/templates to your project’s templates directory.phpDocumentor\Template\AbstractTemplate\AbstractTemplate.Theming:
templates/assets/ to match your Laravel project’s brand (e.g., primary colors, fonts)._variables.scss for theming.Archived Package:
phpDocumentor/phpdocumentor (this template may lag).Template Overrides:
templates/ match the expected structure. Misplaced files (e.g., index.twig in the wrong dir) will break rendering.docs/ directory before regenerating to avoid stale files.Laravel-Specific Quirks:
App\ namespace. Use @package tags explicitly:
/** @package App\Http\Controllers */
__call) unless annotated with @method.Performance:
--processes=4 to parallelize:
vendor/bin/phpdoc -d src -t docs --processes=4
Template Errors:
vendor/bin/phpdoc -d src -t docs --verbose
phpdoc.log for Twig/rendering errors.Missing Assets:
templates/assets/ directory exists and is copied correctly.Custom Templates:
use phpDocumentor\Template\AbstractTemplate\AbstractTemplate;
class MyCustomTemplate extends AbstractTemplate { ... }
phpdoc.php:
'template' => MyCustomTemplate::class,
Plugin Integration:
@plugin tag to integrate with tools like phpDocumentor/parser for custom parsing logic.Twig Filters:
functions.php:
$twig->addFilter(new \Twig\TwigFilter('laravel_namespace', function ($namespace) {
return str_replace('App\\', '', $namespace);
}));
How can I help you explore Laravel packages today?