1. Go to this page and download the library: Download zjkiza/response-processor 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/ */
use ZJKiza\ResponseProcessor\Attribute\ProcessorIdentifier;
use ZJKiza\ResponseProcessor\Attribute\InjectData;
class MediaDto
{
public function __construct(
#[ProcessorIdentifier]
public string $id,
public string $name,
#[InjectData(TagFetcher::class)]
public ?TagDto $tag = null,
#[InjectData(PresenterFetcher::class)]
public ?array $presenters = null,
) {}
}
use ZJKiza\ResponseProcessor\Contract\DataFetcherInterface;
class TagFetcher implements DataFetcherInterface
{
/** @param string[] $identifiers */
public function fetch(iterable $identifiers): array
{
// return ['id1' => TagDto(...), 'id2' => TagDto(...)]
}
}
use ZJKiza\ResponseProcessor\Attribute\Processor;
class MediaController
{
#[Processor('app.tag_handler')]
public function __invoke(): array
{
return [new MediaDto('1', 'Title')];
}
}
#[Processor('app.tag_handler')]
#[Processor('app.presenter_handler')]
public function testAction(): array { ... }
use ZJKiza\ResponseProcessor\Attribute\InjectDataAbstract;
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class InjectPresenter extends InjectDataAbstract {}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.