How to set up the ideal WordPress PHP development environment in Eclipse

I’m really just posting this in case anyone else is looking for help on how to get set up quickly and easily for doing development of WordPress blogs and websites using Eclispe on a local development box.

Everyone at some point needs to set up a blog or simple content-managed website, and although Blogger is great for quick hosted blogsites, and at the other end of the scale web frameworks like Python/Rails are great for custom apps, there is a certain type of site for which WordPress is great.

However, the moment you need to start customizing themes or do any actual dev work, it’s handy to be able to use WordPress with a real development tool like Eclipse. Being able to work in Eclipse brings all the benefits of a sweet IDE, Subversion or other source control, Trac and Mylyn for integrated task management, and first class code editing and debug tools.

I’ve never worked with PHP, so it took me a little while to figure out the best way to get Eclipse set up with PHP and WordPress using PHP Development Tools (PDT), as most of the other references out there talk about PHPEclipse, but the process is straightforward. My set up was with Ubuntu Linux but the steps should be very similar for Mac OSX and Windows.

The basic steps are:
– install Eclipse and PHP Development Tools
– install XAMPP (easy standalone LAMP stack)
– download and set up WordPress and download any themes/plugins
– configure Eclipse projects to point their source to paths linked from XAMPP.

1. Install Eclipse and PDT

I’d recommend the full Eclipse IDE for Java EE Developers Eclipse from http://www.eclipse.org/downloads/ and then install PDT as a plugin from http://www.eclipse.org/pdt/

The easy option if you’re happy to run it standalone is to install Aptana Studio then add the PHP Development Tools (PDT) using the Install Plugins link built in to the starter page:
http://www.aptana.org/studio/download

2. Install XAMPP

XAMPP is a good, easy to configure lamp stack with Apache, MySQL, PHP and more.

There is a good walk-thru of install XAMPP for Ubuntu here:
http://ubuntuforums.org/showthread.php?t=223410

Download XAMPP from http://www.apachefriends.org/

You can either use the bundled myPHPadmin or your regular MySQL Workbench or MySQL GUI tools for administration:
http://dev.mysql.com/downloads/workbench/

Create a wordpress_db database and wordpress_user user account with full privileges on it.

The XAMPP stack runs PHP apps from /opt/lampp/htdocs, so put a link to a working directory in your home path from htdocs with:
cd ~
mkdir ~/public_html
cd /opt/lampp/htdocs
sudo ln -s ~/public_html /opt/lampp/htdocs/$USER

Terminate any existing apache/mysql before running. XAMPP runs from its own /opt/lampp directory separate to any regular apache/mysql servers already installed. There is a neat control panel to bring it up and down.

You can start the server with:
sudo /opt/lampp/lampp start

3. Download WordPress and configure

Download the latest WordPress zip file:
http://wordpress.org/latest.zip

Keep a clean copy somewhere, and for each WordPress project you want to work on, create a folder ~/public/[projectname] and copy the WordPress contents into it.

Customise by adding any downloadable themes to wp-content/themes and plugins to wp-content/plugins.

To save time, I create a master WordPress folder and copy in my favourite themes and regularly used plugins.

4. Configure your project in Eclipse.

Open Eclipse and switch to the PHP Perspective.

Create a new ‘PHP Project’ using the File/New wizard. On the first screen, give the project a name, and select “Create project from existing source” and select the path to the WordPress project folder you created above, and complete the new project wizard.

You can now add this project to source control using a [projectname] right-click “Team/Share Project”, and integrate with tasks etc.

If you make any manual changes to files in the public_html path, remember to right-click the project and Refresh to update them.

Now, to get the WordPress project running, follow the easy WordPress admin installation as per:
http://codex.wordpress.org/Installing_WordPress#Famous_5-Minute_Install

Once you’ve created the database and edited the wp-config.php file, you’ll run the install through a web browser using:
http://localhost/[username]/[projectname]/wp-admin/install.php

Use the wordpress_user and wordpress_db you created earlier.

The WordPress site will run live from the XAMPP Apache path below without needing any further configuration:
http://localhost/[username]/[projectname]

And there you have it. All the power of Eclipse with the simplicity of setting up a WordPress site in PHP.

There are some other useful references here:

PHP Development using Eclipse

Using Eclipse for PHP Development

 

jed

 

10 thoughts on “How to set up the ideal WordPress PHP development environment in Eclipse

  1. Wonderful items from you, man. I have understand your stuff prior to and you are re just extremely fantastic. I really like what you have got here, certainly like what you are stating and the way during which you are saying it. You are making it enjoyable and you continue to care for to stay it sensible. I can’t wait to learn far more from you. This is actually a wonderful website.
    Wish to get a visit web design toronto for latest design and seo tips and solution.

Leave a Reply

Your email address will not be published. Required fields are marked *