I’ve been developing websites for years, and through them I’ve been slowly building up a collection of handy tricks that speed up my development process. I’ve never been a fan of the large frameworks such as symfony (www.symfony-project.org) or CakePHP (www.cakephp.org), choosing rather to have a small code base of handy functions to speed up development.
My most useful “trick” is my MySQL class. While it won’t be the fastest by any means, any pieces of sites that require high speeds I can always code manually. The class supports automatically taking POST / GET items, and inserting them into a database (while escaping all neccessary items), with a simple “$SQL->insert(’tablename’,REQ(array(’field1′,’field2′,’field3′)));
Unfortunately using the word “array” is of the more annoying problems I have with PHP, especially when creating arrays of arrays, a problem that I havn’t yet come up with a solution for (suggestions anyone?)
Another useful way to manage your code, I’ve found is to set up VirtualHost’s on my machine, with hostname “lusion” (for lusion.co.za). This allows me to access the Lusion site with the address http://lusion/, and develop the code based on that. Whenever I finish (and have tested the updated code), putting it live is just a simple rsync command (with –exclude=*config* –exclude=*log*, to avoid overwriting log and configuration files).
The last trick for now, comes in the form of my .htaccess rewrite rules. I use the code
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
That redirects any requests for files that don’t exist (non-images/etc), to index.php. In index.php I handle it so that “website-hosting/php” will search for the files in the following order:
code/website-hosting/php/index.php code/website-hosting/php.php code/website-hosting/index.php code/website-hosting.php
In the case of the lusion site, ‘code/website-hosting.php’ is loaded, which then picks up the /php, and displays php specific website hosting information. This results in great looking (and SEO) URL’s that are clear, and a very organised code base.



