phpdocumentor/unified-asset-installer
Composer custom installer for phpDocumentor assets. Installs packages of type phpdocumentor-template into /data/template instead of /vendor so templates land where phpDocumentor expects them. Intended for template authors; plugin support is planned.
Install the Package
Add the package to your project's composer.json under require-dev (if used for development):
"require-dev": {
"phpdocumentor/unified-asset-installer": "*"
}
Run composer update.
Define a Template or Plugin
Create a composer.json for your template or plugin with the correct type:
{
"name": "your-vendor/template-yourname",
"type": "phpdocumentor-template",
"require": {
"phpdocumentor/unified-asset-installer": "*"
}
}
Trigger Installation
Run composer install or composer update. The installer will automatically place template files in /data/template (or equivalent) instead of /vendor.
Installing a Custom phpDocumentor Template
phpdocumentor/template-custom).composer.json includes "type": "phpdocumentor-template".composer install in your project root. The template assets will now be installed in /data/template (configurable via config.phpDocumentor.php or environment variables).Template Development
"type": "phpdocumentor-template" (or future "phpdocumentor-plugin") to trigger custom installation.Project Setup
composer.json:
"require-dev": {
"your-vendor/template-yourname": "*"
}
composer install to install assets to /data/template.Configuration
// config/phpDocumentor.php
return [
'template' => 'yourname',
'template_dir' => base_path('data/template'),
];
Automation
composer post-install-cmd or post-update-cmd to ensure assets are installed after dependency updates:
"scripts": {
"post-install-cmd": [
"phpdocumentor install-template"
],
"post-update-cmd": [
"phpdocumentor install-template"
]
}
Publish Assets
Create a custom Artisan command to symlink or publish template assets to a Laravel-accessible location (e.g., public/docs):
php artisan vendor:publish --tag=phpdocumentor-assets
Service Provider Register a service provider to dynamically load phpDocumentor configurations:
// app/Providers/PHPDocumentorServiceProvider.php
public function boot()
{
$this->app->singleton('phpdocumentor.config', function () {
return require base_path('config/phpDocumentor.php');
});
}
Testing
Use Laravel’s Artisan::call() to test template installation in PHPUnit:
public function testTemplateInstallation()
{
Artisan::call('composer:install', ['--dev' => true]);
$this->assertFileExists(base_path('data/template/yourname'));
}
Composer Bug Workaround
composer.json due to Composer issue #655."phpdocumentor/unified-asset-installer-z" if needed (though the current name works).Directory Permissions
/data/template (or custom path) is writable by the web server:
mkdir -p data/template && chmod -R 755 data/template
Missing type Field
"type": "phpdocumentor-template" will cause assets to install in /vendor instead of the custom location.Archived Package
Verify Installation Check if assets are installed correctly:
ls data/template
If empty, run composer dump-autoload or clear Composer’s cache:
composer clear-cache
Composer Debug Mode Enable verbose output to diagnose issues:
composer install -v
Custom Installer Logging Add debug logs to the installer (if extending):
// In a custom installer class
file_put_contents(
storage_path('logs/phpdocumentor-installer.log'),
'Debug message: ' . print_r($event, true),
FILE_APPEND
);
Custom Paths
Override the default /data/template path via:
PHP_DOCUMENTOR_TEMPLATE_DIR=/custom/path'template_dir' => env('CUSTOM_TEMPLATE_DIR') to config/phpDocumentor.php.Plugin Support
The TODO in the README suggests future "phpdocumentor-plugin" support. Monitor for updates or implement a similar installer for plugins.
Laravel Mix/Webpack
If using Laravel Mix, exclude /data/template from processing to avoid conflicts:
// webpack.mix.js
mix.exclude('data/template');
Post-Install Hooks Extend the installer to run additional commands (e.g., symlinking):
// In a custom installer class
public function install($composer)
{
$this->postInstallScript = 'php artisan phpdocumentor:link-assets';
parent::install($composer);
}
How can I help you explore Laravel packages today?