I really like using Git and Capistrano to manage my personal projects. If you’re not familiar with Git, it’s a version control system that allows you to track versions of your project. Capistrano is a Ruby utility that allows you to deploy your project to a production server from your local machine with a single command, and easily roll back to a previous version if something goes wrong.
Archive for the ‘PHP’ Category
Customize Joomla Search Component with Mootools
Joomla 1.5 comes with a built-in site search component. The component allows you to create a “search” module for your website, which consists of an input field and a submit button that site visitors can use to search your site. When you create the search module, you can select an image to use in place of the “Submit” button. Search results are displayed in the site’s default template. What if you’d like to change the look of your search form in different parts of your site, however, and display results in more than one template? You can do it with a little bit of Mootools and an easy update to the search component’s controller.
Read more »
Resize and Crop Photos with PHP’s GD Library
I was recently working on a personal project where I wanted to upload photos and, at the same time, carry out the following tasks:
- create a thumbnail of the uploaded image
- resize the image if either its width or height were over 600px and store the resized image rather than the original
- store a caption for the image in a database table
I considered using phpThumb; however, I ran into problems with ImageMagick when I tried saving an image to a file. Googling the problem suggested that I needed to use an older version of ImageMagick, which I was reluctant to do. So I turned to PHP’s GD library, and wrote a class to handle the image-related tasks.
Simple Logging Class for PHP
I hate using “echo” statements in PHP for debugging. Instead, I prefer to tail a log file. I wrote this little logging class that I can include in whatever project I’m working on.
(For Windows users unfamiliar with the tail utility, tail allows you to see data being written to a file in real time when set with the -f (follow) flag. See the manual page for details.)
To use the logger class, add the following to your script:
<?php
include 'logger.php'; //include the logger class
$logger = new Logger(); //instantiate a logger object
?>
If you like, you can pass the logging level of your choice and the path to the log file to the constructor.
Once you’ve done that, you can call any of the class methods on the logger object to write to your log file. I’ve set up the class so you can use four different levels of logging. There are also methods to log the session and the request.
Automated site map for website with dynamically generated pages
We recently launched a website where site visitors can write reviews. Each new review is displayed on its own page, which is generated dynamically from the database. I automated the site map for the site, so that it would be updated whenever a new review was added to the site.



