1. Go to this page and download the library: Download cofa/laravel-api-docs 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/ */
/**
* @group Users
*
* Endpoints for managing user accounts.
*/
class UserController
{
/**
* Create a user
*
* Creates the account and sends the welcome email.
*
* @authenticated
* @header X-Tenant acme The tenant the user belongs to.
* @bodyParam name string source
*/
public function store(StoreUserRequest $request) { /* … */ }
}
use Cofa\ApiDocs\Attributes\{ApiDoc, ApiGroup, ApiHeader, ApiParam, ApiResponse, Authenticated, HideFromDocs};
#[ApiGroup('Users', description: 'Endpoints for managing user accounts.')]
class UserController
{
#[ApiDoc(summary: 'Create a user', description: 'Creates the account and sends the welcome email.')]
#[Authenticated]
#[ApiHeader(name: 'X-Tenant', value: 'acme',
public function bodyParameters(): array
{
return [
'name' => ['description' => 'The full name of the user.', 'example' => 'Ada Lovelace'],
];
}