arangodbfoxxarangojsarangodb-php

How to call ArangoDB Foxx applications from arangodb-php


With ArangoDB-PHP I can easily run AQL querys, but is it possible to use (means "execute") Foxx applications (i.e. when I install foxx/util-sessions-local from https://github.com/arangodb-foxx/util-sessions-local) - how to use the create/update/delete session services by ArangoDB-PHP? Could it be achieved by running AQL or user javascript functions?

A look at ArangoDB-PHP's Transaction class seems to be not the correct solution because it requires read and write collections name ... which I can't provide for more complex Foxx applications.


Solution

  • To the best of my knowledge, you cannot call a foxx-endpoint from inside of an AQL-transaction -- intended is that you use AQL-transactions in your foxx-endpoint code. So if you need to execute stuff transactional you might need to provide additional endpoints that execute the code in question inside of a transactions action.

    To answer the question of the title of your post, there is an easy way to call foxx endpoints with only arangodb-php available (assuming the application returns json-data):

    // $connection is your triagens\Arangodb\Connection instance
    //       ArangodbClient\Connection in newer versions
    $connection->post("/mountpoint/endpoint", $json_body, $headers)->getJson();