Enabling Alfresco PHP Server

From AlfrescoWiki

Jump to: navigation, search

Back to PHP SDK

[edit] Using the Alfresco as a PHP Server

If correctly configured, the Alfresco server can, not only, process PHP file within the repository as templates and scripts, as we have already seen, but can also server PHP files directly from within the Alfresco WAR.

This makes it possible to host an standard PHP application within the same WAR as Alfresco and therefore within the same application server and database. This makes backup/clustering and other administrative task much easier as there is only one application server/database to consider.

PHP application being servered in this manner also have access to the Alfresco PHP API, but since the PHP application is being hosted in the same process connection to the repository is made using the Java native API rather than the Web Service API (as it would using the remote Alfresco lib). This had obvious performance benifits.

NOTE: In version 2.x of the Alfresco repository this functionality is experimental and it is not recommended that it is enabled on a production installation.

[edit] Configuring the Alfresco as a PHP Server

1) Install the PHP AMP

See here for installation details.

2) Open the relevant web.xml file for editing

In order to configure the Alfresco web application to act as a PHP Server the web.xml file of the Alfresco Web Client needs to be modified.

This is best done within the WAR or the expanded WAR once the PHP AMP has been successfully deplyed. Note that any changes to the web.xml made in the way will be overwriten when a new WAR is deloyed.

The web.xml file can be found in the WEB-INF directory of the Alfresco WAR.

3) Add the following configuration to the web.xml file


   <!-- Add at the end of the existing servlet tags -->

   <servlet>
     <servlet-name>QuercusServlet</servlet-name>
     <servlet-class>org.alfresco.module.phpIntegration.servlet.AlfrescoQuercusServlet</servlet-class>
   </servlet>

   ...

   <!-- Add at the end of the existing servlet-mapping tags -->

   <servlet-mapping>
      <servlet-name>QuercusServlet</servlet-name>
      <url-pattern>*.php</url-pattern>
   </servlet-mapping>

4) Restart the application server


[edit] Testing PHP Server from the Alfresco WAR