An Introduction to PHP Wax
A Web Framework for PHP
The more we write and design web applications the more it becomes obvious that the majority share a core set of functionality.
The simple things that you may do day in and day out such as querying a database, creating forms, sending emails and structuring a website layout often involves a great deal of repetitive work.
It's for this reason that a well designed framework can help us to become much more efficient as well as helping to produce software with fewer bugs.
Why PHP Wax?
Many frameworks are designed to be accessible to all competencies of programmers which often results in software that is bloated or unnecessarily abstracted.
First up PHP Wax is designed for developers working in a professional environment with a good knowledge of object oriented programming. If you're more used to procedural style programming then you may want to do a little swotting before you get stuck in.
The second thing to remember is that often, PHP Wax will use some of the more advanced features of the PHP language so you will need to have a fairly up to date version of the language and occasionally the ability to install extra dependencies too.
Finally by way of a warning there are several features that will not work on Windows platforms. Whilst your application should run without any problems there's a few nice extra scripts included that will only work on Mac and Linux systems.
If all that doesn't scare you off then sit back and start to enjoy programming again.
Your First Application
So it's about time we got started on an application and your first job is to grab a copy of the framework and a basic skeleton application.
First up we'll get a skeleton application downloaded to your machine. This consists mainly of a few files that help you put your files in the right place.
Getting The Skeleton
Download the current skeleton from:
http://github.com/phpwax/wax-site/zipball/master
Unzip the file and rename the top folder to the name of your application or a test name if your not planning on doing anything serious at the moment. The best place to put this is in your 'Sites' directory on your computer.
Now you have the skeleton application you just need a copy of the framework. It works really simply, inside your folder that you've just created you need to have the framework files in a folder called wax.
Getting PHP Wax with Git
PHP Wax uses the Git VCS to manage development so if you want to easily update the framework code as new features are added then we'd recommend that you use Git to clone the PHP Wax repository.
If you have Git installed on your system then pop open a terminal window, navigate to your sites directory and type the following:
git clone git://github.com/phpwax/phpwax.git wax
Getting a PHP Wax ZIP File
If you don't have GiT on your machine you can get a zip snapshot of the current version of PHP Wax here:
http://github.com/phpwax/phpwax/zipball/v2-stable
Once you've downloaded and unzipped this file, just rename the top folder to wax, and move the folder into your skeleton application folder.
See Your Application In Action
We're almost there so it's about time we saw what our application looks like. To do this you'll need to set up your local web server to serve from the public directory. Normally you'd setup a local domain name and then a virtual host within Apache to serve it.
On OS X or Linux you can edit your /etc/hosts file add 127.0.0.1 testapp.local and you have a local domain.
Then open up your Apache config file and add something like the following:
<VirtualHost *:80>
DocumentRoot "/Users/yourusername/Sites/testapp/public"
ServerName testapp.local
</VirtualHost>
Please note that the path file above presumes an OS X architecture.
On some systems you may have to restart Apache.
Then all that remains is to open your browser and type:
http://testapp.local
Congratulations, you're ready to go.
Example Sites to Help get you Started
To try and help there are some basic example sites in GiT repositories / zip files available to download:
