1. Go to this page and download the library: Download php-nl/laravel-api-doc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php-nl / laravel-api-doc example snippets
use PhpNl\LaravelApiDoc\Attributes\ApiDoc;
#[ApiDoc(group: 'Product Management', name: 'Update Product', description: 'Modify an existing product.')]
public function update(Request $request, Product $product)
{
// ...
}
use PhpNl\LaravelApiDoc\Attributes\QueryParam;
use PhpNl\LaravelApiDoc\Attributes\BodyParam;
#[QueryParam('sort', type: 'string', description: 'Field to sort by', enumValues: ['asc', 'desc'])]
#[BodyParam('notify_user', type: 'boolean',
use PhpNl\LaravelApiDoc\Attributes\Unauthenticated;
#[Unauthenticated]
public function login(Request $request)
{
// ...
}
'routes' => [
'e by URL wildcards
'exclude' => [
'api/internal/*',
'api/webhooks/*',
],
// Exclude by Route Name
'exclude_names' => [
'admin.*',
'horizon.*',
],
// Exclude by assigned Middleware
'exclude_middleware' => [
'auth:admin',
],
],
use PhpNl\LaravelApiDoc\Attributes\ExcludeFromDocs;
#[ExcludeFromDocs]
class SecretController extends Controller
{
// ...
}
return [
'ui' => [
'title' => 'My API Documentation',
'theme' => [
'primary_color' => '#3b82f6', // Customize your brand color!
'background_color' => '#f8fafc',
'sidebar_width' => '300px',
],
'docs_path' => resource_path('docs/api'), // Where your custom .md files live
],
// ...
];