Tracking PHP errors

track_errors provides the means to catch an error message emitted from PHP. It’s something I like to use during the development of various applications, or to get a handle on legacy code. Here are a few examples why! For example Imagine the following remote HTTP call: So whenever this call fails, it will return false and also emit an error message: Some people use @ to suppress this error message — an absolute no-go for reasons such as:...

November 27, 2010 · 2 min

Magento: Loading the product from a template

When I wrangle with Magento Commerce and customize anything, every other bit is of course tied to a product’s ID, or sometimes entity ID. The challenging part is that whenever you’re in a template in Magento, the scope is very different from the previous one. This is sometimes frustrating, but when you think of it — it makes sense. That is, in Magento! ;-) Magento works in blocks and each block is basically a class file, of course $this is never the same....

November 24, 2010 · 2 min

APC: get a key's expiration time

It’s always surprising to me, but APC is still the best kept secret. APC offers a bunch of very useful features — foremost a realpath cache and an opcode cache. However, my favorite is neither: it’s being able to cache data in shared memory. How so? Simple: use apc_store() and apc_fetch() to persist data between requests. The other day, I wanted use a key’s expiration date to send the appropriate headers (Expires and Last-Modified) to the client, but it didn’t seem like APC supports this out of the box yet....

November 8, 2010 · 1 min

PHP SDK for Amazon Web Services

Yesterday, Jeff Barr announced Amazon’s own PHP SDK for their web services — own, because AWS hired CloudFusion’s lead developer earlier this year (in March) and I guess after a while they decided it was time to incorporate his open source efforts into the company. The full story is on getcloudfusion.com. So what? What’s more than just pretty interesting about all of this, is that not only is the AWS PHP SDK hosted on Github (bonus points for sure), but since it implements almost the entire API of all infrastructural services and is backed by the API provider, this library currently presents the most feasible way for PHP developers to work with AWS....

September 29, 2010 · 2 min

Debugging Zend_Test

Sometimes, I have to debug unit tests and usually this is a situation I’m trying to avoid. If I have to spend too much time debugging a test it’s usually a bad test. Which usually means that it’s too complex. However, with Zend_Test_PHPUnit_ControllerTestCase, it’s often not the actual test, but the framework. This is not just tedious for myself, it’s also not the most supportive fact when I ask my developers to write tests....

September 20, 2010 · 3 min