Saturday, June 27, 2009

How to debug a Zend Framework application in Ubuntu

Why I wanted to debug Zend Framework
I got started with CodeIgniter, and I later found out that it's designed to not work well with debuggers. There are CodeIgniter forum posts dating as far back as 2007 where you can get instructions on how to patch the source code and tweak the config files so that query string (GET params) work, which XDebug and Zend Debugger both need to work. I spent hours trying to debug with Aptana PHP (plugin 1.0 and 1.1 Beta) and Eclipse PDT, and failed. I decided to trash a framework so backwards as CodeIgniter.

How to
If you don't want to install Zend Platform (the paid PHP server), it may not be much too intuitive how to hit the ground running with a sample Zend Framework project and be able to debug it. Here's who I finally managed. (I use Ubuntu 9.04)

echo 'deb http://repos.zend.com/deb/ce ce non-free' | sudo tee -a /etc/apt/sources.list
wget http://repos.zend.com/deb/zend.key -O- | sudo apt-key add -
sudo aptitude update

sudo apt-get install zend-ce

Add PHP to your path:
sudo ln -s /usr/local/zend/bin/php /usr/local/bin/php

  • Install Zend Studio for Eclipse from http://www.zend.com/en/products/studio/downloads. I used Studio 6.1. Zend Studio is not free! It costs $400 and comes with a 30-day trial. You can try also with Eclipse PDT, which is the free (scaled-down) version of Studio.
  • Download the project Zend Quickstart and unzip it. I renamed my directory zend-quickstart. We'll call the root <path to project's root>
In <path to project's root> run, as instructed by the README.TXT file:
php scripts/load.sqlite.php --withdata
chmod -R a+rwX data
  • Counter intuitively, the Debug command in Zend Studio doesn't actually deploy your project to the PHP server, so you need to do that yourself. By default the document root for Zend CE is /var/www
ln -s <path to project's root> /var/www/myprojecturl   (you can change myprojecturl obviously)
Now you can access the project at http://localhost/myprojecturl
  • Back in Studio, go to Run==>Debug Configurations. Configure this:
File: zend-quickstart/public/index.php
Server Debugger: Zend Debugger

Click PHP Server Configure. Go to Path Mapping tab, and Add:
* Path on Server: myprojecturl
* Local path: /zend-quickstart

Make sure the URL generated is correct. Should be /myprojecturl/public/index.php
  • Cool! Click the Debug button now, and the debugger should be stopped at the first line of the index.php script. Breakpoints should work.

My favorite Firefox addons

To add a Firefox addon, go to the Tools->Addons menu, and on the first (Get Addons) tab, search for the name of the addon.

  • Cookie Swap: Instantly switch between different accounts in the same web site (e.g., Gmail). Forget about logging off and back.
  • Firebug: No web developer can do without it.
  • Google Toolbar: It's good to know the PageRank of the company you're checking out. It's like asking the rest of the world how good they are, and getting a single digit for an answer.
  • NetVideoHunter: Download videos from video sharing sites (e.g., Youtube and others)
  • TabGroups Manager: Organize your zillions of open tabs!
  • Tabs Open Relative: Who at Mozilla came up with this idea that when you open a link in a new tab it should open at the far right? Fix it with this plugin.
  • Restart Firefox: Don't want to close all your open firefox windows before restarting? Use this. (You should have many firefox windows if you're using TabGroups, but...)
  • Tiny Menu: Reclaim your valuable vertical screen space.

Saturday, June 20, 2009

"Facebook API "Fatal error: Call to undefined method FacebookRestClient::stream_get() in ..."

Fatal error: Call to undefined method FacebookRestClient::stream_get() in /home/aptana/domains/x.aptanacloud.com/web/htdocs/index.php on line 18



NOTE: If you're using the official PHP client library and you downloaded it from the example code link on the Developer Application, you may have gotten an outdated release that doesn't contain the stream_get method and others released recently, and thus you'll get runtime errors. Use the official Facebook PHP Client Library package from SVN for the latest code.