Category Archives: PHP

Traits, Exceptions, and Better Automated Tests

I really, really dig 5.4′s traits. Let’s review: Through the ‘use’ keyword, traits let you include shared functionality in a class without relying on inheritance or encapsulation of another class. With the exception of declaring static variables (you can’t), and referencing parent (will call the class you’re using the trait in), traits behave just like [...]

Also posted in Programming | Leave a comment

Traits + Interfaces in PHP 5.4 – The Perfect Team

PHP has been getting consistently better over the past few years. One new feature that I’m really pleased with is traits, which is similar to multiple inheritance in Java, friend classes in C++ or mixins in Ruby and Python. Basically, traits allow your classes to share functionality without constructing any objects or inheriting from any [...]

Also posted in Programming | Comments closed

CodeIgniter / Expression Engine Nashville – Slides

Slides from CodeIgniter / EE Nashville Talk

Also posted in CodeIgniter | Leave a comment

How Well Do You Understand “Static” Variables?

Today I realized that I did not completely understand the “static” keyword as it applies to variables, which is used in many programming languages. If you weren’t aware of the full breadth of how the static keyword alters a variable, this post should be a mind blower. So, let’s start simple. Take the following example [...]

Also posted in Abstract, Programming, Software Design | 2 Comments

Understanding Singletons

Why ANOTHER article about Singletons? If you search for ‘Singleton’ in Google or StackOverflow you get a bajillion and a half results.  That makes sense, because it’s one of the most commonly implemented design patterns in the history of software.  Some reasons for the popularity of the Singleton are: A.  It makes more intuitive sense [...]

Also posted in C++, JavaScript, Programming | Leave a comment

Add support for dbase in php 5.3.8

PHP’s dbase extension allows you to work with .dbf files in PHP. After php 5.2, you can no longer compile php with dbase support, so here’s how you can add it to your php installation: 1. Download dbase: 2. Extract and cd into. 3. sudo phpize 4. sudo ./configure && sudo make && sudo [...]

Also posted in Programming | Leave a comment

Getting HMVC to play nicely with deeply nested config files in Sparks

I was recently debugging an issue with Codeigniter Payments and HMVC. The issue was that config files were not being loaded if they were deeply nested – for example: config/payments/my_gateway.php The MX_Config path explodes the filepath provided on forward slashes, so if you do anything other than this->load->config(‘whatever’), the file you want won’t get loaded, [...]

Also posted in CodeIgniter, Programming | 2 Comments

Common PHP Compile Configuration Options

I’ve been compiling PHP from source lately. Some common baseline options I’m using: sudo ./configure –with-mysql –with-apxs2=/usr/sbin/apxs –with-mcrypt=/usr/local/src/php-5.3.8/ext/mcrypt –with-config-file-path=/etc –with-openssl In my local dev environment, I place all my language source files in /usr/local/src (ie php 5.3.8) and then symlink any needed command line features. For example /bin/php would symlink to /usr/local/src/sapi/cli. That way, If [...]

Also posted in Programming | Comments closed

FuelPHP Package for Working with Campaign Monitor API

Continuing my “Do it Yourself” exploratory programming trend, I took one look at the CampaignMonitor SDK today and decided I’d write my own. Their API is RESTful, well documented, and easy to work with, so why not? Here is the final product:—CampaignMonitor-API-Package What I like about this API wrapper is the simplicity, and specifying [...]

Also posted in FuelPHP, Programming | 5 Comments

Automatically Install WordPress Plugins when Your Theme is Installed

The thought of making a wordpress theme and requiring users to install plugins needed to make it work sounds pretty sucky. The thought of taking plugins and hardcoding them into my theme sounds even suckier. …And I hate things that suck. So here is how you can automatically install wordpress plugins when your theme loads: [...]

Also posted in Wordpress | 3 Comments