PHP code example of ehyiah / apidoc-bundle
1. Go to this page and download the library: Download ehyiah/apidoc-bundle 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/ */
ehyiah / apidoc-bundle example snippets
namespace App\ApiDoc;
use Ehyiah\ApiDocBundle\Builder\ApiDocBuilder;
use Ehyiah\ApiDocBundle\Interfaces\ApiDocConfigInterface;
class UserDocConfig implements ApiDocConfigInterface
{
public function configure(ApiDocBuilder $builder): void
{
$builder
->addRoute()
->path('/api/users/{id}')
->method('GET')
->summary('Get user by ID')
->tag('Users')
->response(200)
->description('User details')
->jsonContent()
->ref('#/components/schemas/User')
->end()
->end()
->end();
}
}
use Ehyiah\ApiDocBundle\Attributes\ApiDoc;
use App\ApiDoc\UserDocConfig;
class UserController
{
#[ApiDoc(UserDocConfig::class)]
public function getUser(int $id) { /* ... */ }
}