CodeIgniter sess_destroy not working, session not deleting

•August 16, 2011 • Leave a Comment

CodeIgniter uses cookies for session management by default, therefore you can’t use any native commands to help you out with session handling. Using the native PHP session, you can destroy the session in one line and follow it up with another line that expects the session to be cleared.

This cannot be done with CodeIgniter’s sess_destroy. This usage is typical in user authentication, here is an example scenario:
Continue reading ‘CodeIgniter sess_destroy not working, session not deleting’

PHP CodeSniffer Cheat Sheet

•June 2, 2011 • Leave a Comment

In an effort to build coding standards for our team, I recently began looking at PHP CodeSniffer.
PHP CodeSniffer is a great tool to define and enforce coding standards with PHP.

Its usage can be very simple:
Continue reading ‘PHP CodeSniffer Cheat Sheet’

PHP Pear install location on Ubuntu

•May 31, 2011 • 1 Comment

Pear installs packages in the following directory on Ubuntu 10.04:


/usr/share/php/PHP/

Unable to load dynamic library mhash.so

•May 19, 2011 • 2 Comments

I’ve been procrastinating on fixing this annoying error from PHP on Ubuntu 10.04:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20090626/mhash.so’ – /usr/lib/php5/20090626/mhash.so: cannot open shared object file: No such file or directory in Unknown on line 0

The fix is to purge the mhash package:
Continue reading ‘Unable to load dynamic library mhash.so’

Call to undefined method PEAR::raiseErro()

•May 4, 2011 • Leave a Comment

I went to install PHPMD on my Ubuntu dev box, and received the following error:


Call to undefined method PEAR::raiseErro() in /usr/share/php/PEAR/REST.php on line 165

This was easily cleared up by running the following command:

mkdir -p /tmp/pear/cache

PHP – strip leading slashes, strip trailing slashes

•April 27, 2011 • 2 Comments

There is often a time when you need to strip the leading or trailing slashes from a string, usually a directory or url. Stripping the trailing and leading slashes is incredibly easy with PHP using the rtrim, and/or the ltrim function(s). It is so easy that I even hesitated to write this post… that was until I searched Google. Now, it seems necessary to make this post, as you can quickly find the wrong way to do it (no offense meant to author).

Without further ado, here are some examples:
Continue reading ‘PHP – strip leading slashes, strip trailing slashes’

Avoid Apache 404 on encoded url

•March 28, 2011 • Leave a Comment

There are times when you need to use an encode param in a url or GET request. More than often, this encoding is done out of security concerns so that some script kiddy doesn’t get happy shoving data into your urls.
Continue reading ‘Avoid Apache 404 on encoded url’

Simple deployments made easy using rsync with a Makefile

•March 17, 2011 • Leave a Comment

Automated methods for code deployment more than often make the developer happy. The deployment method described here uses rsync and a Makefile to easily sync a local site with a remote site, or the other way around.

Continue reading ‘Simple deployments made easy using rsync with a Makefile’

CodeIgniter – get controller name and method name

•March 2, 2011 • 9 Comments

Recently, I had situation where I needed to get the name of the current controller.

Initially I was just going to use the URI class. However, I happened upon two useful methods that would provide the name of the current controller and the name of the current method:

Continue reading ‘CodeIgniter – get controller name and method name’

Turn off or Disable Apache Acess Log

•February 13, 2011 • 1 Comment

There are times when it is necessary to turn off or disable the access logs for Apache, whether it be for user anonymity or the log rotation hasn’t been set up.
This is a relatively easy task, just add/update the following in the Apache conf file for your virtual host:

CustomLog /dev/null