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:
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:
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:
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:
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:
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:
Once you’ve created the database and edited the wp-config.php file, you’ll run the install through a web browser using:
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:
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