Client SDKs

PHP Automation Client

Updated: September 22, 2017 Page Information Edit on GitHub

The Nuxeo Automation PHP Client is a PHP client library for Nuxeo Automation API.

It is compatible with Nuxeo Platform LTS 2015, LTS 2016 and latest Fast Tracks.

Path to the PHP Client (v1.5)

Version 1.5.0 introduces a new fluent API. The old API is still available. Thus you can upgrade the library to the 1.5 version and access the new API and features without breaking your application.

version < 1.5.0

$client = new \Nuxeo\Automation\Client\NuxeoPhpAutomationClient('http://localhost:8080/nuxeo/site/automation');
$session = $client->getSession('Administrator', 'Administrator');
$answer = $session->newRequest("Document.Query")->set('params', 'query', "SELECT * FROM Document)->setSchema($propertiesSchema)->sendRequest();
$documentsArray = $answer->getDocumentList();

version >= 1.5.0

$client = new \Nuxeo\Client\Api\NuxeoClient('http://localhost:8080/nuxeo', 'Administrator', 'Administrator');
$documents = $client->schemas("*")->automation('Document.Query')->param('query', 'SELECT * FROM Document')->execute(Documents::className);

Getting Started

Library import

Download the latest stable release Nuxeo Automation PHP Client 1.5.0.

Composer:

  "require": {
    "nuxeo/nuxeo-automation-php-client": "~1.5.0"
  }

Usage

Creating a Client

The following documentation and samples applies for the 1.5 and newer versions. Calls to the Automation API for previous versions of the client will require adjustments.

For a given url:

$url = 'http://localhost:8080/nuxeo';

And given credentials:

use Nuxeo\Client\Api\NuxeoClient;

$client = new NuxeoClient($url, 'Administrator', 'Administrator');

Options:

// For defining all schemas
$client = $client->schemas("*");
// For changing authentication method

use Nuxeo\Client\Api\Auth\PortalSSOAuthentication;
use Nuxeo\Client\Api\Auth\TokenAuthentication;

// PortalSSOAuthentication with nuxeo-platform-login-portal-sso
$client = $client->setAuthenticationMethod(new PortalSSOAuthentication($secret, $username));

// TokenAuthentication
$client = $client->setAuthenticationMethod(new TokenAuthentication($token));

APIs

Automation API

To use the Automation API, Nuxeo\Client\Api\NuxeoClient#automation() is the entry point for all calls:

use Nuxeo\Client\Api\Objects\Document;

// Fetch the root document
$result = $client->automation('Repository.GetDocument')->param("value", "/")->execute(Document::className);
use Nuxeo\Client\Api\Objects\Documents;

// Execute query
$operation = $client->automation('Repository.Query')->param('query', 'SELECT * FROM Document');
$result = $operation->execute(Documents::className);
use Nuxeo\Client\Api\Objects\Blob\Blob;
use Nuxeo\Client\Api\Objects\Blob\Blobs;

// To upload|download blob(s)

$fileBlob = Blob::fromFile('/local/file.txt', 'text/plain');
$blob = $client->automation('Blob.AttachOnDocument')->param('document', '/folder/file')->input($fileBlob)->execute(Blob::className);

$inputBlobs = new Blobs();
$inputBlobs->add('/local/file1.txt', 'text/plain');
$inputBlobs->add('/local/file2.txt', 'text/plain');
$blobs = $client->automation('Blob.AttachOnDocument')->param('xpath', 'files:files')->param('document', '/folder/file')->input($inputBlobs)->execute(Blobs::className);

$resultBlob = $client->automation('Document.GetBlob')->input('folder/file')->execute(Blob::className);

Errors/Exceptions

The main exception type is Nuxeo\Client\Internals\Spi\NuxeoClientException and contains:

  • The HTTP error status code (666 for internal errors)
  • An info message
3 days ago manonlumeau NXDOC-1323: Update BDE doc
3 years ago Vincent Dutat 17
3 years ago Manon Lumeau 16
3 years ago Frédéric Vadon 15 | The name of the client changed because of https://github.com/nuxeo/nuxeo-automation-php-client/commit/560874cfd9662b2b464045b19c6819e10a834600
4 years ago Solen Guitter 14
4 years ago Solen Guitter 13 | Added TOC and excerpt
5 years ago Solen Guitter 11 | Fixed file:content interpreted as a link
5 years ago Solen Guitter 12 | Migrated to Confluence 4.0
6 years ago Arthur Gallouin 10
6 years ago Arthur Gallouin 9
6 years ago Arthur Gallouin 8
6 years ago Alain Escaffre 7
6 years ago Arthur Gallouin 6
6 years ago Arthur Gallouin 5
6 years ago Arthur Gallouin 4
6 years ago Arthur Gallouin 3
6 years ago Arthur Gallouin 2
6 years ago Arthur Gallouin 1
History: Created by Arthur Gallouin