1. Go to this page and download the library: Download orbito/render-client 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/ */
orbito / render-client example snippets
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Log\LoggerInterface;
use Orbito\RenderClient\RenderClient;
use Orbito\RenderClient\TemplateRef;
use Orbito\RenderClient\TemplateOptimize;
$render_client = new RenderClient(
[
'default' => 'http://localhost:4250',
],
ClientInterface $http_client,
RequestFactoryInterface $request_factory,
StreamFactoryInterface $stream_factory,
LoggerInterface $logger,
);
$content = $this->renderer->render(
'default', 'en', 'main',
new TemplateRef('my-tpl', 'pages/default'),
TemplateOptimize::makeFor('html'),
[],// data
[],// styleVars
['renderText' => true],// optional, options
null|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;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.