PHP code example of timostamm / protoc-h1-php-server
1. Go to this page and download the library: Download timostamm/protoc-h1-php-server 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/ */
timostamm / protoc-h1-php-server example snippets
#[Route(path: '{serviceName}/{methodName}', methods: ['PUT'])]
public function execute(RequestInterface $request, string $serviceName, string $methodName): Response
{
$resolver = new ServiceResolver();
$resolver->registerInstance(
SearchServiceInterface::class, // the interface generated by protoc
new SearchService() // your implementation of the interface
);
$handler = new HttpHandler($resolver);
// turn on details in error messages
$handler->setDebug(true);
// will log exception details, regardless of debug mode
$handler->setLogger($myPsrLogger);
return $handler->handle($serviceName, $methodName, $request);
}