Alfresco PHP Library Installation Instructions
From AlfrescoWiki
Back to PHP SDK
Contents |
[edit] Download
The Alfresco PHP library can be downloaded from here.
Alternatively, if you are building Alfresco from the SVN repository, you can do the following:
- build Alfresco with the PHP module: for this, do a ant package-php-war (this deploys the module into the alfresco.war in the web-client distribution build, see the console output of the ant command),
- check out a copy of modules/php-sdk/source/php/remote from the SVN repository to a place accessible by your web-server (in the documentation below, this latter place will be called the "install directoy").
[edit] Prerequisites
- Alfresco 2.0 (or higher) repository (Hint: some people have encountered difficulties using Apache 2.2 on Win with PHP)
- PHP 5.x
- Apache 2.0 configured with PHP (or similar)
Hint: this web site has some helpful tips on installing Apache 2.0 on WinXP php.net
[edit] Instructions
- Unpack the contents of the Alfresco PHP library into a convenient directory, retaining the directory structure.
- Ensure that the following SOAP extensions are installed/enabled by editing your php.ini to include the following. (Hint: this may differ slightly on a non-Windows installation)
extension=php_mysql.dll extension=php_sockets.dll extension=php_soap.dll
- On linux with php 5.x you do not need these entries in php.ini. Just type php -m and check for mysql, sockets and soap.
- Edit your php.ini file and add the install directory to your include path. For example:
include_path="<the existing include path>:<your install directory>"
Hint: have a look here for a brief introduction on how to set the PHP include path.
- Configure your web server to include /alfresco as virtual directory. This directory should map to the directory into which you unpacked the PHP library. (Configuring Apache For The Alfresco PHP Library)
- Start your Alfresco repository
- Run the sample scripts to ensure correct installation
[edit] Running The Sample Scripts
Configuring The Samples
- Edit the <ALFRESCO-PHP-LIBRARY_HOME>/Examples/config.php file
- Modify the repository URL and connection credentials as required
- Save and close config.php
- The default configuration is as follows:
$repositoryUrl = "http://localhost:8080/alfresco/api"; $userName = "admin"; $password = "admin";
Hint: The repository URL points to the Axis end-point location for the repository that you wish the samples to connect to.
Query Executer
- Open http://myserver/alfresco/Examples/QueryExecuter/queryExecuter.php
- The following web page should be shown:
- Select the store you want to query from the list in the drop-down control, enter a valid Lucene query and click the 'Submit Query' button.
- Results from the query should be displayed.
Hint: A good Lucene query to try is TEXT:"Alfresco", note that double-quotes are used to denote a string.
Document Browser
- Open http://myserver/alfresco/Examples/SimpleBrowse/index.php
- The following should be displayed:
- Clicking on a space will navigate into that space
- Clicking on a content item will show the content in the browser
- The breadcrumb control at the top of the page can be used to navigate back up the space hierarchy.
[edit] Running The Unit Tests
Why Unit Tests?
The PHP library is shipped with a number of unit tests that test the core features of the PHP library. They do not necessarily provide good code examples, but do provide a way of easily checking the "health" of the PHP library and its connection to the repository.
Under normal circumstances it is not nessesary to run the unit tests unless you are experiencing some difficulties and wish to check that the PHP library is functioning as expected.
Unit tests are used throughout the product and the PHP library is no exception.
Installing PHPUnit2
Before you can run any of the unit tests you need to install the PEAR package PHPUnit2.
Details on the package can be found here [1]
Configuring The Unit Tests
- Open the file 'my-install-dir/Tests/alfresco/BaseTest.php'
- Look for the following code:
const USERNAME = "admin"; const PASSWORD = "admin"; const URL = "http://localhost:8080/alfresco/api";
- Modify the username, password and URL as required.
- Save and close the file.
Running The Unit Test
- Browse to the URL http://myserver/alfresco/Tests
- The following page should be shown:
- Enter the tests you want to execute in the edit bax provided. Enter a new test location on seperate line. In order to execute all the unit test enter the following into the edit box:
alfresco/ContentTest alfresco/NodeTest alfresco/SessionTest alfresco/StoreTest alfresco/VersionTest alfresco/RepositoryTest alfresco/NamespaceMapTest
Hint: Click on the test history link to get a list of recently run tests.
- Click on the 'Run Tests' button to execute tests and wait for result.
- Once the tests have executed the following view will be shown:
- Any test failures will be displayed on this page and can be used to diagnose any problems.

