Combine the Power of Nuxeo PHP Automation Client with Symfony
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.
[gist id=cf943198bc7926431707 file=packagist.json]
Anyone 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!
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.