CategoryDevelopment

Web development related information

Numeric range queries using Zend_Search_Lucene, working around the bugs

Zend_Search_Lucene is a PHP implementation of the Lucene full-text searching engine. Whilst some of it works well, other bits don’t quite, such as performing range queries. The most common error for range queries is along the lines of an Zend_Search_Lucene_Search_QueryParserException that states Range query boundary terms… This, as may have guessed, is that queries that work fine in...

Use Zend_Log_Writer_Firebug to debug AJAX requests using Firebug

Debugging a page request in PHP, simple right? Either output to the page or command-line using something like var_dump, or use a step-through debugger to go through line-by-line. The advantage of the former is that it’s quick, and although the latter is more thorough it can be quite time-consuming. However when you’re debugging an AJAX request, you can’t simply output as...

Using Zend_Db_Profiler_Firebug to show database queries per page

Although ZFDebug is a great tool, it does require you to show the toolbar when you need to check something. Whilst this is fine for developers or administrators, it’ll probably confuse regular users. Therefore if you’re trying to debug something a regular user is doing, you may need another way to see what database queries are being run. Luckily Zend Framework has both a logger and a...

Checking $mixed parameter type for PHP methods

Something that we came across this morning, and something to be wary of in the future, is how you check the parameter type of a $mixed variable in a method signature. i.e. Is the parameter a string or a number? If you’re not careful you can get unexpected results… As we’ve discovered, using ctype functions can be dangerous as ctype_digit() for example expects a string as a...

“concrete5 cannot parse the PATH_INFO or ORIG_PATH_INFO information provided by your server.”

Thought I’d take a look into concrete5 to see what is was like, and it’s the first open source PHP project installer I’ve come across in ages that complained about anything other than filesystem permissions. PATH_INFO? Most other projects use different mechanisms/variables to do a similar job I assume… Anyways, go to the concrete5 install directory and create a .htaccess...

VirtualBox Guest Additions with Shared Folders for Linux Virtual Machines on Mac OS X

In order to access certain aspects of a virtual machine in VirtualBox, you will need to install Guest Additions (similar to VMWare Tools I guess) There is a manual page for installing Guest Additions but not all of it is self-explanatory… First you need to log into your Linux virtual machine (VM) and install/configure x, y and z. Install DKMS This part is relatively straightforward, just...

Using PHP late static binding to define static arrays as subsets for child classes

OK, the title might sound a little confusing, but the concept it relatively simple. Basically it’s using an array in a child class that contains some of the items that appear in the array in the parent class. Which just means you have a list of all of the things in the parent, and a list of some of those things in every child. Like a list of options such as colours, types, etc. Imagine that...

Zend Server lighttp not running (phpMyAdmin) but Apache is? How to start it manually

If for some reason you’ve powered on and while Apache seems to be running OK, lighttp isn’t (for example phpMyAdmin isn’t working on localhost:10081/phpmyadmin) then you will need to start it manually. This is probably caused by a dirty restart, such as a power failure. On Mac OS X run this command… sudo /usr/local/zend/bin/lighttpdctl.sh start For Windows, I’m...

Zend Framework 1.8+ Module/Library Autoloading

Given the problems I had for the 1st Zend Framework website I did, I figured the next time I started one from scratch I would document how to get the autoloading working, since almost nowhere has it documented correctly. I forgot then too, so 3rd time lucky… The following code assumes the following: You have no model, controller or view directories at the root of application/ because they...

Testing and timing RDS/MySQL scheduled downtime with PHP

Something I was asked at work recently was “if we do this to the server, how long will it be unavailable for?” and usually the answer would be easy… however in certain circumstances you may not know. One of these is Amazon RDS, whereby you don’t really know what happens when you reboot or change the configuration of an instance, it just sort-of happens and eventually...