Month: April 2007

Using Alfresco’s PHP API

Alfresco is starting to incorporate more and more PHP into the platform. This is exciting for us at Optaros because we’ve built some great PHP-based solutions for clients and we’ve had a lot of success with the productivity PHP brings to front-end developers. But, the PHP world lacks an enterprise ready, highly-scalable, robust content management repository.

Now hold on! Hear me out. Projects like Drupal and Joomla are great for certain types of requirements. There are many large, extremely high-volume sites built with Drupal. What I’m talking about is something more generic. Something that makes zero assumptions about the presentation. I’m talking about a back-end repository for rich content plus the back-end “library services” typically associated with document management systems such as workflow, versioning, security, extensible data model, etc. Think “Zope” without the ZODB that can run in any servlet container.
Alfresco has had a PHP API for a while but until today I hadn’t had a chance to do anything with it. On the plane home from Boston today I decided to take it for a spin (details at the bottom of this post).

Using PHP with Alfresco

If you want to write PHP applications that leverage content in Alfresco you can do that today with the PHP API. The PHP API leverages Alfresco Web Services. I have not yet confirmed whether you can do everything with the PHP API that you can with the Java-based Alfresco Web Services API but theoretically you should be able to. And, if you want to write your own Alfresco-centric web services you can–you could deploy them in the same Axis container as Alfresco’s and then hit them with PHP.

If you want to manage a web site using Alfresco WCM that uses PHP you can do that today. But when you use the Alfresco Virtualization Server your PHP scripts won’t run because the Virtualization Server is a customized version of Apache Tomcat and it doesn’t know how to run PHP. Alfresco may address that in the near future.

If Alfresco expands the use of PHP within the product, Alfresco may become more than just an ECM suite–it could become a powerful platform for Next Generation Internet applications. Until then, the next time your PHP application needs a loosely-coupled content repository, consider standing up Alfresco and hitting it with the PHP API.

Trying out the Alfresco PHP API

Once you get all of the pieces together it isn’t that hard to run the Alfresco PHP samples. But it’s not extremely well documented so I’ve included some pointers here. My stack is Ubuntu Dapper Drake, MySQL, Alfresco 2.0 Enterprise, PHP 5.2.1.

  1. Download PHP 5 from http://www.php.net. Follow the directions for building, configuring, and making PHP. When you configure php, make sure to include the –enable-soap flag. You’ll also need to uncomment the extension=php_soap.dll line in your php.ini file.
  2. Use Pear to install Pear::SOAP and its dependencies. (UPDATE: Per Lukas’ comment below, this step is not needed.)
  3. The Alfresco PHP API on the community download site is still at version 1.2. The latest and greatest Alfresco PHP API can be found in the source tree under “modules”.
  4. Follow the instructions in modules/php-sdk/source/php/remote/installation.txt to set up the samples. (See below for how my files were set up).
  • Created a directory called /usr/local/lib/alfresco.
  • Created an alias and a Directory entry in httpd.conf that points to /usr/local/lib/alfresco per the installation.txt file.
  • Copied the contents of modules/php-sdk/source/php/remote to /usr/local/lib/alfresco.
  • Added /usr/local/lib/alfresco to my include_path in my php.ini file.

If your Alfresco repository is running and you’ve restarted Apache with the updated httpd.conf and php.ini, you should be good to go. On my system, I can check /var/log/apache/error.log to troubleshoot. If everything is okay, when you point your browser to http://localhost/alfresco/Examples/SimpleBrowse you will see a list of the spaces and content in your Alfresco store. You can navigate the list, open documents, etc.

The other example is the QueryExecuter example. It performs a full-text query and presents a node list of the query results.

Both of these are very simple examples but by looking at the code, the PHP API source under the Alfresco directory, and the Alfresco Web Services SDK, you should be able to see how you can incorporate Alfresco into your PHP-based application.

SalesForce.com targets Documentum with new ECM functionality

According to CMSWatch, SalesForce.com is going to begin offering ECM capability. The post says the SalesForce.com CEO is boasting that customers can get rid of their Documentum implementations. For some clients who may be under-utilizing Documentum, that could be true. But I imagine SalesForce.com is going to have a lot of work to do to get its acquired Koral software at the functional level required to supplant most large Documentum installations.