Skip to content

Repository files navigation

Orbito\RenderClient

Latest Stable VersionLatest Unstable VersioncodecovTotal DownloadsGithub actions BuildPHP Version Require

HTTP client to use with Orbito Render.

composer require orbito/render-client
usePsr\Http\Client\ClientInterface;
usePsr\Http\Message\RequestFactoryInterface;
usePsr\Http\Message\StreamFactoryInterface;
usePsr\Log\LoggerInterface;
useOrbito\RenderClient\RenderClient;
useOrbito\RenderClient\TemplateRef;
useOrbito\RenderClient\TemplateOptimize;
$render_client = newRenderClient(
[
'default' => 'http://localhost:4250',
],
ClientInterface $http_client,
RequestFactoryInterface $request_factory,
StreamFactoryInterface $stream_factory,
LoggerInterface $logger,
);
$content = $this->renderer->render(
'default', 'en', 'main',
newTemplateRef('my-tpl', 'pages/default'),
TemplateOptimize::makeFor('html'),
[],// data
[],// styleVars
['renderText' => true],// optional, optionsnull|string,// optional, trace for logging
);
if(!$content) {
return;
}
error_log('Rendered in ' . $content->renderTime . 'ms');
$html = $content->rendered;
$style = $this->renderer->style(
'default', 'main', 'my-tpl',
['nanoCss' => true, 'cssAutoPrefix' => false],
[],// styleVars
);
if(!$style) {
return;
}
error_log('Generated style in ' . $style->styleTime . 'ms');
$css = $style->style;

Dev Notices

Commands to set up and run e.g. tests:

# on windows:
docker run -it --rm -v %cd%:/app composer install
docker run -it --rm -v %cd%:/var/www/html php:8-cli-alpine sh
docker run --rm -v %cd%:/var/www/html php:8-cli-alpine sh -c "cd /var/www/html && ./vendor/bin/phpunit --testdox -c phpunit-ci.xml --bootstrap vendor/autoload.php"# on unix:
docker run -it --rm -v `pwd`:/app composer install
docker run -it --rm -v `pwd`:/var/www/html php:8-cli-alpine sh
docker run --rm -v `pwd`:/var/www/html php:8-cli-alpine sh -c "cd /var/www/html && ./vendor/bin/phpunit --testdox -c phpunit-ci.xml --bootstrap vendor/autoload.php"

Versions

This project adheres to semver, until 1.0.0 and beginning with 0.1.0: all 0.x.0 releases are like MAJOR releases and all 0.0.x like MINOR or PATCH, modules below 0.1.0 should be considered experimental.

License

This project is free software distributed under the MIT LICENSE.

MIT License

© 2022 bemit

Contributors

By committing your code to the code repository you agree to release the code under the MIT License attached to the repository.


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages