Late Static Binding namespace resolution in PHP

If you try to get the namespace of the child class that you are in using the __NAMESPACE__ keyword, you will have the same problem that you do using functions like get_class() in that you will get the namespace (or class) where the current method you are calling is defined. $namespace = __NAMESPACE__; $class = ...

Capistrano website deployment with PHP Composer

Composer is great for handling PHP dependencies, and Capistrano is great for automated deployment, so wouldn’t it be great if you could use them together? To do this, all you need to do is update your recipe with the following task, then add a hook to make it run when the recipe is used. To ...

Concrete5 “Fatal error: Class ‘View’ not found”

Concrete5 may present you with the confusing error “Fatal error: Class ‘View’ not found”, which looks like a Loader issue but often it is not. When moving between different servers, the database permissions may not be quite right, which will cause this to happen. If you check that the user that Concrete5 is using has access to ...

How to safely handle PHP “__toString() must not throw an exception”

Because there is no safe way to handle an exception thrown during __toString the easiest workaround for this is to catch all exceptions thrown and return either an empty string or null. Since any invocation of __toString will expect a string back, it is a graceful way to handle any under-the-hood errors if you’re using __toString ...

“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 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 ...

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 ...

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 ...

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 ...

Newer posts
Older posts