1. Go to this page and download the library: Download gdbots/ncr 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/ */
gdbots / ncr example snippets
$query = IndexQueryBuilder::create(SchemaQName::fromString('acme:user'), 'email', '[email protected]')
->setCount(1)
->build();
$result = $this->ncr->findNodeRefs($query);
if (!$result->count()) {
throw new NodeNotFound('Unable to find homer.');
}
$node = $this->ncr->getNode($result->getNodeRefs()[0]);
foreach ($ncr->pipeNodes(SchemaQName::fromString('acme:article')) as $node) {
echo json_encode($node) . PHP_EOL;
}
$node1 = $cache->getNode($nodeRef);
$node2 = $cache->getNode($nodeRef);
$node->equals($node2); // returns true if their data is the same
public function onSearchNodesResponse(ResponseCreatedEvent $pbjxEvent): void
{
$response = $pbjxEvent->getResponse();
if (!$response->has('nodes')) {
return;
}
// for all nodes in this search response, mark the creator
// and updater for lazy load. if they get requested at some point
// in the current request, it will be batched for optimal performance
$this->lazyLoader->addEmbeddedNodeRefs($response->get('nodes'), [
'creator_ref' => 'acme:user',
'updater_ref' => 'acme:user',
]);
}