Setting up a Linux development environment
This is a step-by-step guide for setting up a Linux development environment for Apache log4php.
At the end of this procedure you will be able to:
- run unit tests
- generate site and documentation
- create a new release
- have a good starting point for development
This guide starts with a clean installation of Ubuntu 11.04 (Natty Narwhal). No optional packages (such as web server, php, lampp, etc.) have been installed during OS installation.
The OS installation is not covered by this document.
Root access is presumed. If you are not logged in as root, you must prefix each command with "sudo". To log in as root in Ubuntu, first log in as user, then execute "sudo su -".
- Git for repository access
- PHPUnit for unit testing
- ApiGen for generating documentation
- Xdebug for generating code coverage
- Apache Maven 3 for the build process
- MongoDB server for testing the MongoDB appender
Required PHP extensions:
- PDO_SQLITE for testing the PDO appender
- mongo for testing the MongoDB appender
- cURL is a pre-requisite for PHPUnit
Required PEAR components:
- PEAR_PackageFileManager2 for creating the PEAR package
Most required components are available from the Ubuntu package repository.
At the time of writing this guide, some of the packages (namely PackageFileManager2) had dependancies which were not yet stable. This will cause the following error:
To install them, PEAR has to be adjusted to accept beta packages (be sure to switch it back to stable afterwards):
First, make sure that PEAR is fully upgraded, and enable auto-discovery of cahnnels:
The following packges can be installed from PEAR and PECL:
Prerequisites for testing the MongoDB appender.
To activate mongo extension, add the following line to the php.ini file:
Apache Maven 3 manual install
On newer Ubuntu distributions Apache Maven is available in the package repository. Disregard this chapter if you have already installed it using apt-get or similar.
However if not, you can install manually by following the following steps.
Java runtime must be installed to run Apache Maven. OpenJDK runtime works.
Instaling Apache Maven
Download the latest 3.x binaries from the Maven download page and unpack them to a desired location. These instructions assume you chose /usr/local/apache-maven.
Setting environment variables
Maven requires several environment variables to work.
If bash shell is used, these lines can be added to the end of the ~/.bashrc file so they will be automatically applied on each logon.
Testing the installation
Test the installation by running:
This should produce output similar to:
Testing the environment
Now all required software has been installed.
Clone the Apache log4php source repository.
Now you can:
Note that Maven will download it's own dependancies as required. This may take a while, but it is only performed once.