Skip to content
Michal Štefaňák edited this page Jan 26, 2023 · 15 revisions

Deepr PHP implementation

This library has very simple and straightforward usage. You just have to pass instance of class and query to Deepr. Here is sample code:

$json = '<some json string>';
$query = json_decode($json, true);
//deserialize input

class Root { }
$root = new Root();

$deepr = new \Deepr\Deepr();
$result = $deepr->invokeQuery($root, $query);

//serialize output
print_r($result);

Deserialization

Important part is to properly deserialize request query before calling invokeQuery.

This step should contains:

  • Instantiation of class by source value requests. More info
  • Applying filter by accessibility. Every public method and property is available for Deepr. If you want to limit this, you have to implement it in this step.
  • Additional authorization by access rights. If authorizer isn't enough (Options).

You can find inspiration in tests Deserializer.

Serialization

Result of invokeQuery has to be formatted for output. You can use standard json_encode but if your query contains nesting, you have to do some post processing in this step.

You can find inspiration in tests Serializer.

How is query processed against structure

Check Deepr features wiki.

Options

Main nethod invokeQuery accepts argument with options. Check wiki page Options to see what is available.