Latest stories

“Your proxy directory must be writable”

When you first start off with Doctrine 2, you’ll eventually start creating complex objects with child objects as properties, which of course you will use Doctrine to load. Unlike how you’d do it traditionally though, Doctrine uses proxy pattern objects to lazy-load these child objects until they are accessed; these objects are cached, and thus the proxy directory just like the cache...

“The class ‘x’ was not found in the chain configured namespaces”

If you are getting a namespace chain error when trying to load entities with Doctrine 2 in Zend Framework 2, it is likely because as far as Doctrine is concerned the namespace your entity is in is missing. If you’ve copied Jason Grime’s Doctrine 2 and Zend Framework 2 tutorial then you’ll notice the configuration he places in module.config.php array( 'doctrine' =>...

RIJNDAEL encryption with PHP, 256-bit using IV

I had a bit of trouble finding a how-to of how to encrypt and decrypt using RIJNDAEL, so I put together a quick example of how to using a non-blank IV. However I did find a useful code snippet from Chilkat Software that helped me a lot of the way. The only gotcha I found is that if you generate an RIJNDAEL 256 CBC key and IV using OpenSSL it will generate a 64-bit key and 32-bit IV, even though...

How to install CentOS 6 on Microsoft Hyper-V virtualization

Many developers rely on Linux, but often work in a Windows infrastructure environment. Often it’s not feasible to install a flow-blown VSphere or XenServer setup when everything else runs on Windows Server and there’s limited hardware, but virtualization has many advantages. Enter Hyper-V, which can be looked after by Windows system administrators, but let you use Linux in virtual...

Get Android stack trace from device using Debug Bridge

Instead of crashing, sometimes your Android application will stop responding and dump a stack trace to the device. You probably will not be able to access this using Android File Transfer, and if you view it using the Dalvik Debug Monitor Server (DDMS) the data directory will probably appear empty. You can get the file using the Android Debug Bridge (ADB) however. The easiest way to set this up...

Using ZFDebug for Zend Framework with database and cache

ZFDebug is a Zend Framework plugin to debug and analyse your web application as it bootstraps, so that you can see how long everything takes to load, including how many database and cache calls are made. Having used ZFDebug in the past, it’s a handy tool but somewhat light on documentation. Here is a simple way to set it up to debug your database and cache calls, which should be placed...

Using Zend_Pdf and Zend_Pdf_Image with remote URL’s (files)

Zend_Pdf is a handy component of Zend Framework, but expects you to use local files. However if you need to open files that are located on a different server (such as an Amazon S3 bucket) you will need a way of getting them into Zend_Pdf first. $pdf = Zend_Pdf::load($pdfUrl); One solution is to stream them in via a string… $pdf = Zend_Pdf::parse(file_get_contents($pdfUrl)); Similarly, if...

Copying files in Red Hat/CentOS without prompting, -f –force flag being ignored

Something annoying about Red Hat/CentOS/Fedora I had forgotten after years of Debian, Ubuntu and SuSE (or something that they’ve introduced recently, I’m not sure) is that cp is an alias to cp -i, as in it is interactive by default. Therefore the following will still prompt you for overwriting: cp * -Rf /var/somewhere/new_location To get around this just use the cp binary directly...

iPhone simulator (emulator) on Mac OS X Lion

Quick way to get easier access to the iPhone Simulator that comes with XCode
ln -s \
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ \
Simulator.app /Applications/iPhone\ Simulator.app

Extract slugs from URL’s in MySQL

So, say for a database update, which for some reason you cannot script using your normal scripting language, you need to extract a part of a URL (a slug for example) from a complete URL
SELECT TRIM(BOTH '/' FROM SUBSTRING(TRIM(LEADING '/' FROM link_url),
locate('/', TRIM(LEADING '/' FROM link_url)))) FROM page_links