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 |
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 |
Slides from CodeIgniter / EE Nashville Talk http://www.calvinfroedge.com/slide-decks/codeigniter-ee-nashville-03-12.pdf
Also posted in CodeIgniter |
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 [...]
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 [...]
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: http://pecl.php.net/get/dbase 2. Extract and cd into. 3. sudo phpize 4. sudo ./configure && sudo make && sudo [...]
Also posted in Programming |
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, [...]
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 |
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: https://github.com/calvinfroedge/FuelPHP—CampaignMonitor-API-Package What I like about this API wrapper is the simplicity, and specifying [...]
Also posted in FuelPHP, Programming |
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 |