pear

HOWTO: Enable PEAR on OS-X XAMPP

The current, OS-X version of XAMPP comes with PEAR but it's not installed/configured.

Here is what you need to do:

sudo su -  [and type admin password]
/Applications/xampp/xamppfiles/lib/php/pear install PEAR
/Applications/xampp/xamppfiles/lib/php/pear install Log
/Applications/xampp/xamppfiles/lib/php/pear list 

The last command outputs the list of installed pear modules. Log should be one of them.

Once you configure pear and install Log plugin, you need to add PEAR to include_path in XAMPP's php.ini.

Edit /Applications/xampp/etc/php.ini and at the very end of the file note the lines:

1133 ;***** Added by go-pear
1134 include_path=".:/Applications/xampp/xamppfiles/lib/php"
1135 ;*****

change the configuration to read:

include_path = ".:/Applications/xampp/xamppfiles/lib/php
                 :/Applications/xampp/xamppfiles/lib/php/pear"

(comment: of course, the entire include_path must be on the same line, we had to break it at semicolon to avoid the long line destroying the page layout).

Drupal: Debugging with PEAR Logging

Let's admit, any PHP developer, at some point has "debugged" a PHP application by inserting several "echo" statements here and there. It's easy and quick but it's by far not the best way. For one, you can not and should not do anything like that on a production server. The last thing users need to see is debug messages from a desperate developer. Besides, in the ever-increasing Ajaxization of web-applications the "echo approach" simply does not work, anymore. Ajaxized server-side code is executed without having any direct, "echo-compliant" output in the response HTML stream. It's time to get used to logging to a file on the server.

Unfortunately, at the time of this writing, Drupal does not have built-in support for file logging. Could be because somebody thought the cumbersome database-logging was more than enough, could be because PEAR Log already provides the functionality. Either way, let's see how we can Integrate PEAR Log in our Drupal development.

First, we need to initialize the logger, by putting the following code in index.php, preferrably after the boostrap and before the call to menu_execute_active_handler().

Syndicate content