Sunday, September 20, 2009

Setting up a PHP development environment on Sabayon 4.2

Most of the steps I've taken to setup a PHP development environment on Sabayon will work on other distributions, you will need to find out how to install applications (such as from a repository for your particular choice of distribution). I have chosen to add Apachefriend's XAMPP for Linux and the Scintilla Editor (SciTE), there are other Linux-Apache-MySQL-PHP projects you can use as well as a plethora of editors which you can try out to find the best editor for you. These are my personal choice for quick setup/install and configuration not to mention the ability to quickly migrate to another platform and the ease of backing up and restore.

Step 1: Download and Install XAMPP for Linux.

This is an easy step, simply download the tarball from apachefriends.org - for consistency I install XAMPP for Linux in the /opt/ directory - for specific instructions on installing XAMPP or any other LAMP project, you can find instructions included on the project's website and in the tarball.

Once installed, I like to add a 'www' in my Desktop folder to the freshly installed htdocs folder:

# ln -s /opt/lampp/htdocs /home/andrew/Desktop/www

Also setting the permissions for the link (if the system allows)

# cd /home/username/Desktop
# chown -h nobody:username ./www


As well as the permissions for the htdocs directory itself - for multiple development users you can add them to a group and use that instead of the single username for the group ownership

# cd /opt/lampp/
# chown nobody:username ./htdocs


I also like to setup my system with 'dev' as the hostname, if you want to do this you can append 'dev' (or anything else you would like to use for the hostname) to the hostnames in the /etc/hosts file. I like to do this to shorten the url: http://dev/projectname rather than http://localhost/projectname.

Step 2: Install and configure editor

I'm fairly keen on the Scintilla Editor (SciTE), it has been the best cross-platform editor I have used for development with PHP. In Linux I usually pick up SciTE from the repository (usually under the development group), for Windows I download from the website directly: http://www.scintilla.org/

After installing, I like to edit the SciTEGlobal.properties file, when installed in Sabayon 4.2, this is located in /usr/share/scite/ - to enable line numbers and the toolbar (this only involves uncommenting the appropriate line).

Step 3: Develop!

I'm lucky in this regard, I have a project I am currently working on - if you're new to PHP you might like to look at some working open source code - in my humble opinion this is the best way of learning new ways of doing things with PHP. I use svn to do a checkout of my latest revision:

$ cd /home/username/Desktop/www
$ svn co https://aphpkb.svn.sourceforge.net/svnroot/aphpkb aphpkb


There are many great projects to learn from and there is no better time to get into PHP!

No comments:

Post a Comment