• to the beginning
    home
  • rss syndication
    entries
  • rss syndication
    comments
  • to the bottom
    down
#ekynoxe
development / design / photography

Zend and Xdebug

September 17, 2009 //
0

After having coded most of my sites all from scratch with some of my own libraries, I am getting into using Zend framework, PHPUnit, and Xdebug.

If the two first ones have been of little trouble to install, I can’t say the same for Xdebug.

At first I have followed all the common tutorials that you can find around the web:

  • downloading the pre-compiled xdebug.so for my PHP install
  • simply copying to the proper folder
  • modifying my php.ini configuration by adding the correct zend_extension parameter for [xdebug].

Until here, nothing fancy, it seems to work for most. BUT, when every install how-to on the web says “that’s it you’re done”, nothing happened for me. Xdebug was not loaded, there was no error message and everything was still running fine.

That’s when things started to get complicated, given the amount of combination possible of wrong configuration parameters and pre-compiled available shared objects, all of which would fail silently if anything would go wrong.

I tried to change zend_extension to zend_extension_ts because I was running PHP 5.2.8, but this did not change anything, I tried to compile xdebug.so manually and use the compiled object with the several parameters combination I have already tested with the pre-compiled version… Nothing. not single error or idicatio that could put me on the right way!

Then, I came across an old article on devzone.zend.com that I have discarded at first for its age (December 2007…) but that I ended up reading thoroughly and the following lines flashed before me:

Please note that phpize and php-config must match the PHP version you are using, so do not just copy them to your system from some other PHP installation. When your development tools are in place, you can download and compile xdebug

The phpize command on my system was not pointing to the proper one, as I compiled my own AMP install on the Mac. Running the proper phpize (in /usr/local/php/bin/ for me), it gave kind of a weird result:

PHP Api Version: 20041225
Zend Module Api No:
Zend Extension Api No:

Yep! No Zend API version numbers at all. As phpise is a simple shell script that extracts the API numbers from the PHP and Zend configurations, I thought there was a problem simply with my PHP install, and not with xdebug at all.

As I was running 5.2.8, I upgraded to PHP 5.3, cleaned all xdebug.so files, cleaned my php.ini file and tried it all again!

The pre-compiled version DID NOT WORK either, but compiling it myself from source, this time phpize giving the right API numbers:

PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

And finally xdebug worked!
So, a few things to remember:

  • sort your PHP install properly first, with the commands pointing to the right places. That’s also valid for php-config that is required for the compilation of xdebug
  • trying the pre-compiled version might not work on your system, so compile your own, it’s simple enough and the article on zend.com(http://devzone.zend.com/article/2803), albeit old, is still valid

Fix that Web Site!

September 9, 2009 //
0

I can’t recall how many times I’ve entered a domain name in a browser, say ‘domain.com’, only to wait 30 seconds and get an ugly 502 Bad gateway error in return.
The problem? Enter http://domain.com instead of http://www.domain.com and see what happens.

  1. you are served the expected website, the url stays the same
  2. you are redirected to http://www.domain.com or some other url
  3. you get a 502, Bad gateway timeout

I don’t know if it’s laziness, lack of knowledge or simply host providers being plain rubbish, but it’s an annoying problem that can be solved extremely simply!

Most of websites that are not configured properly often get away with it as many internet users believe that ‘www’ is a compulsory part of any web URL.
In fact it’s only because of an old practice of naming hosts according to the services they provide, in our case a web site, with www. FTP using ftp.domain.come etc.
But it has nothing to do with any technical issue or any standard.
Not many (if any) ‘Mr average’ know this!

One of the problems is that with the advent of new web browsers that suggest you URLs from your history, or even perform straight away an interactive search of web resources that match your typing, it is very easy to fall into the usual consumer laziness and let the browser find everything for you. That way, you get into the habit of accessing a website just by typing the domain name, without www or any other prefix, and sometimes even without the top level domain (The ‘.com’ or other ‘.something’).

I’m the first to do it and that’s why I probably end up on these poorly configured web servers from time to time.
But I am still quite astonished to it see happen, as it can seriously lead to some misunderstanding from the average user. If I don’t know anything of internet, don’t care about ‘www’s, just type a domain name in my browser and get an error page, I’m not going to try very long to search for how to access that site!

That problem has a simple solution though.

First, if you have access to them, check your DNS records.
This step might not be compulsory, but it won’t harm to check them anyways.
Your domain will have an A record to point your domain name to the IP of the host of your web site:

domain.com        A         0.0.0.0

You can also add either an A or a CNAME record for the www sub-domain. The syntax differs:

domain.com A 0.0.0.0
www.domain.com        A 0.0.0.0
www.domain.com CNAME domain.com.

Second, check your web server configuration that it actually is accepting requests from sub-domains and serving the proper files.
In Apache, for example, you can set it up by adding a virtual host:

Listen 80
NameVirtualHost *


<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>


<VirtualHost *>
ServerName domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>

or using a server alias:

Listen 80
NameVirtualHost *


<VirtualHost *>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>

So yes, I admit, you have to have access to the DNS entries and the configuration files of the server. But even if you don’t and it’s down to the host provider to configure the DNS and the web server files, it is very easy to set these up properly.

Ok, again, you might argue that you could serve a different version of the site with http://domain.com and http://www.domain.com, but if you don’t and there is no redirection in place, just make sure you don’t serve a 502.

setting-up Zend

September 7, 2009 //
0

Installing the Zend framework on an old Power Mac G5 on Tiger, I ran into a common PHP library problem.

After copying the whole Zend package into my php include folder, trying to use the project creation script gave me the following Manifest error:

zf.sh create project quickstart
Fatal error: Uncaught exception ‘Zend_Tool_Framework_Manifest_Exception’ with message ‘A provider provided by the Zend_Tool_Framework_Manifest_ManifestBadProvider does not implement Zend_Tool_Framework_Provider_Interface’ in /usr/local/lib/php/ZendFramework-1.9.2/library/Zend/Tool/Framework/Manifest/Repository.php:100
Stack trace:
#0 /usr/local/lib/php/ZendFramework-1.9.2/library/Zend/Tool/Framework/Loader/Abstract.php(104): Zend_Tool_Framework_Manifest_Repository->addManifest(Object(Zend_Tool_Framework_Manifest_ManifestBadProvider))
#1 /usr/local/lib/php/ZendFramework-1.9.2/library/Zend/Tool/Framework/Client/Abstract.php(118): Zend_Tool_Framework_Loader_Abstract->load()
#2 /usr/local/lib/php/ZendFramework-1.9.2/library/Zend/Tool/Framework/Client/Abstract.php(209): Zend_Tool_Framework_Client_Abstract->initialize()
#3 /usr/local/lib/php/ZendFramework-1.9.2/library/Zend/Tool/Framework/Client/Console.php(96): Zend_Tool_Framework_Client_Abstract->dispatch()
#4 /usr/local/lib/php/ZendFramework-1.9.2/bin/zf.php(214): Zend_Tool_ in /usr/local/lib/php/ZendFramework-1.9.2/library/Zend/Tool/Framework/Manifest/Repository.php on line 100

It turned out that the Zend tool was finding the wrong provider in the unit tests directory. I’m still not sure about what happens, but removing the test folder from the include_path did the trick.

However, I did scratch my head a bit on the following:

Fatal error: Cannot redeclare class Zend_OpenId_Provider in /usr/local/lib/php/ZendFramework-1.9.2/library/Zend/OpenId/Provider.php on line 44

After a bit of searching, I discovered two things:

  • Don’t put the Zend framework package directory in any subdirectory of your document root or it will be picked up as well
  • Clean your server from any other Zend libraries before trying to use a new one! Seems obvious enough, but when you are appointed a machine with lots of ‘history’ (let’s keep it that way), you can’t always do what you want…

Zend has now been installed, but I am still not really happy about having to separate the whole framework directory (eg, removing the test directory) in order to have things working.
Anyone has an update on this?

Edit – Setting up the environment variable ZEND_TOOL_INCLUDE_PATH to the proper library on the server solves this as well. In particular, the first finding above is not valid anymore, but it doesn’t prevent you from doing a bit of house cleaning anyways ;)

BadOps

August 30, 2009 //
0

The latest of ekynoxe’s design and developments: http://badops.zapee.com.

badops

Badops is slowly arrive to maturity as an online tool to report bad behaving radio operators.
The brief for this project was that simple:

  • Total freedom on the design
  • Simplicity of the interface for only a few functions
  • ability to integrate later design and functionality requirements

In other words, a perfect project for me!
Especially on the design part, the total freedom allowed me to get down to something refreshing. A bit on the flashy side, I admit, but hey, the goal is to nail these bad-ops!

Work is still going on as requirements are coming in, but there is plenty of room to add more content on that website.

Newer Entries »
  • Links

    • Wordpress
    • Development Blog
    • Plugins
    • Themes
    • Suggest Ideas
    • Support Forum
  • Tag Cloud

    Apache authlogic CSS design development DNS gentoo git gitosis javascript mobile motivation Orange organisation ruby security thoughts UX work xdebug Zend
  • Categories

    • Apache
    • authlogic
    • conferences
    • CSS
    • design
    • git
    • javascript
    • mobile
    • Orange
    • ruby
    • Uncategorized
    • UX
    • work project
    • Zend
Wu Wei by Jeff Ngan.
back to the top