1. Go to this page and download the library: Download nazg/heredity 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/ */
nazg / heredity example snippets
hack
use type Nazg\Http\Server\RequestHandlerInterface;
use type Facebook\Experimental\Http\Message\ServerRequestInterface;
use type Facebook\Experimental\Http\Message\ResponseInterface;
use type Ytake\Hungrr\Response;
use type Ytake\Hungrr\StatusCode;
use type NazgHeredityTest\Middleware\MockMiddleware;
use namespace HH\Lib\Experimental\IO;
use function json_encode;
final class SimpleRequestHandler implements RequestHandlerInterface {
public function handle(
IO\WriteHandle $handle,
ServerRequestInterface $request
): ResponseInterface {
$header = $request->getHeader(MockMiddleware::MOCK_HEADER);
if (count($header)) {
$handle->rawWriteBlocking(json_encode($header));
return new Response($handle, StatusCode::OK);
}
$handle->rawWriteBlocking(json_encode([]));
return new Response($handle, StatusCode::OK);
}
}
hack
use namespace HH\Lib\Str;
use type Nazg\Http\Server\AsyncMiddlewareInterface;
use type Nazg\Heredity\Exception\MiddlewareResolvingException;
use type Nazg\Heredity\Resolvable;
use type Nazg\Glue\Container;
class GlueResolver implements Resolvable<AsyncMiddlewareInterface> {
public function __construct(
protected Container $container
) {}
public function resolve(
classname<AsyncMiddlewareInterface> $middleware
): AsyncMiddlewareInterface {
if ($this->container->has($middleware)) {
return $this->container->get($middleware);
}
throw new MiddlewareResolvingException(
Str\format('Identifier "%s" is not binding.', $middleware),
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.