So I'm using phpDocumentor 3 to generate documentation for my Laravel 7 project,
and was wondering if I could serve this documentation (static files) from Laravel in order to make it available only to authorized users.
I would like to be able to update the documentation through my CI/CD, so I can't just modify manually the generated documentation.
I think that I might have to write my own template (https://docs.phpdoc.org/3.0/guide/guides/templates.html) for that but I'm not sure whether the documentation is incomplete or if I'm missing something because I have no idea how to create a template. Any suggestions, guides or tutorials that can help me achieve this please ?
Thank you
You can include the phpDoc generation within your CI/CD script:
first install the phpDocumentor
on the production, then generate using this command:
phpDocumentor -d . -t storage/docs/
Note: the
storage
path maybe is gitIgnored if you plan to generate the phpDocs, not on the production server, you have to be sure that the folder will be pushed to the production
add this to the config/filesystem.php
'disks':
'local-docs' => [
'driver' => 'local',
'root' => storage_path('docs'),
],
and add the following in your routes file (routes/web.php
)
Route::get('/docs/{url?}', function ($url) {
$resp = response(Storage::disk('local-docs')->get($url));
$resp->header('content-type', GuzzleHttp\Psr7\MimeType::fromFilename($url));
return $resp;
})->where('url', '(.*)')->middleware('auth');
be sure you haven't any other route with the
docs
prefix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With