1. Go to this page and download the library: Download zrnik/zweist 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/ */
zrnik / zweist example snippets
class HelloWorldController
{
public function __construct(
private readonly \Zrnik\Zweist\Content\JsonContentFacade $jsonContentFacade,
) {}
/**
* @param array<string, string> $arguments
* @throws JsonException
*/
#[
Get(
path: '/api/hello/{name:.*}',
operationId: 'Say Hello',
description: 'says hello by the request parameter',
),
Response(
response: 200,
description: 'when ok',
content: new JsonContent(ref: TestResponse::class)
),
Middleware(ExampleMiddleware::class),
]
public function sayHello(
RequestInterface $request,
ResponseInterface $response,
array $arguments = []
): ResponseInterface
{
return $this->jsonContentFacade->updateResponse(
$response,
new TestResponse(
sprintf(
'Hello, %s :)',
$arguments['name']
)
)
);
}
}