Combine the Power of Nuxeo PHP Automation Client with Symfony


Thu 11 February 2016 By Pierre-Gildas Millon

The Nuxeo Platform’s flexible and extensible REST API makes it easy for you to use your favorite programming language and build a customized interface, while fully leveraging the Nuxeo Platform and its features. To make it even easier, we have some pre-built client libraries. One of them is the Nuxeo PHP Automation Client. It allows you to access the platform from any PHP application through the REST API. Today, I will show you how easy it is to leverage the power of this Automation Client.

With the recent release of Nuxeo Platform LTS 2015, we reviewed the client packaging and decided to distribute it via Packagist. This means that it's available to any PHP project using composer:

[gist id=cf943198bc7926431707 file=packagist.json]

symfonyAnyone who knows PHP must have heard about Symfony - the leading PHP framework to create websites and web applications. In this blog, I will show how to use this new packaging of Nuxeo PHP Automation Client in a very simple Symfony 3 project. Let's get started!

The Steps

First, edit the composer.json file to add the nuxeo-automation-php-client dependency :


[gist id=cf943198bc7926431707 file=composer-excerpt.json]

Then, create some convenient parameters and a nuxeo service in the app/config/services.yml file :

[gist id=cf943198bc7926431707 file=services.yml]

Finally, in a controller you can get the nuxeo service and fetch any document :


[gist id=cf943198bc7926431707 file=index-action.php]

Here, I fetched a simple Note-type document with an HTML content that I use as the landing page of my Symfony application.

You can also fetch a document by searching from some SEO title field created in Nuxeo Studio and approved documents by using something like:


[gist id=cf943198bc7926431707 file=getblog-action.php]
I hope this article inspired you to create PHP websites leveraging the ease of Symfony and the power of the Nuxeo Platform.


Tagged: Nuxeo Automation, php, REST API