1. Go to this page and download the library: Download domainflow/http 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/ */
domainflow / http example snippets
use DomainFlow\Http\Attribute\Route;
#[Route(method: 'GET', path: '/hello/{name}', name: 'hello')]
final class HelloEndpoint
{
public function __invoke(HelloRequest $request): array
{
return ['message' => 'Hello, ' . $request->name . '!'];
}
}
final readonly class HelloRequest
{
public function __construct(public string $name)
{
}
}
#[Route(
method: 'GET',
path: '/reports/{reportId}',
host: '{tenant}.api.example.test',
)]
final class TenantReportEndpoint
{
public function __invoke(): void
{
}
}
// https://acme.api.example.test/reports/42
// routeParameters: ['reportId' => '42', 'tenant' => 'acme']
sh
cd examples/runtime
composer install
php -S 127.0.0.1:8080 -t public public/index.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.