PHP custom debugging functions

Here is another debugging helper for Symfony, CodeIgniter, Kohana and Zend frameworks or your applications. Normally you would use var_dump() or print _r() for debugging but dumping the data without xdebug always a pain.

I use these custom functions depending on type of data whether an array or a class to debug my code which makes it more friendly and human-readable.



<?php

function my_print_r ($param$bool TRUE) {
    
preprint_r($param$bool), FALSE);
}

function 
my_var_dump ($param) {
    
pre(var_dump($param));
}

function 
my_debug ($param) {
    if (
is_object($param)) {
        
pre('Object: ['.get_class($param). '] => '
           
print_r(array_keys(get_object_vars($param)), TRUE), FALSE);
    }
}

function 
my_debug_in ($param) {
    if (
is_object($param)) {
        
pre('Object: [' .get_class($param).' ] => Array'FALSE);
        foreach (
get_object_vars($param) as $key) {
            
my_debug($key);
        }
    }
    if (
is_array($param)) {
        
my_print_r($param);
    }
}

function 
my_class($name NULL) {
    
$class = new ReflectionClass($name);
    
my_print_r(Reflection::export($class));
    
}

function 
pre($param$bool TRUE) {
    if (!
ini_get('xdebug.default_enable') || !$bool) {
        echo 
"<pre>".$param ."</pre>\n";
    }else {
        echo 
$param;
    }
}

?>

Symfony and sfDoctrineGuard missing installation point

If you are getting the 500 error (Call to undefined method myUser::isAnonymous.) after installing the sfGuardDoctrine plugin i.e

Call to undefined method myUser::isAnonymous.

Add these lines in your apps/app name/config/factories.yml to make to pluging to work.

all:
  user:
   class:  sfGuardSecurityUser

Using th native MySQL ENUM type in Symfony 1.4 and Doctrine

To use the native MySQL ENUM type in Symfony and Doctrine you will have to update your "project/config/databases.yml" and add the "use_native_enum" directive under "attributes" i.e:
      attributes:        
         use_native_enum: true
         use_dql_callbacks: true
         default_table_collate: utf8_general_ci
         default_table_charset: utf8

Full Version

Daryush Shokof the director of Iran Zendan gone missing in Germany

Iranian director Daryush Shokof has disappeared after his latest film “Iran Zendan” was premiered three weeks ago in the cinema “Babylon” in Berlin. The Iran Zendan draws a very true picture about inhumanity of torture and rape in the prisons of the Islamic Republic in Iran.

Daryush lives in Berlin for decades and headed to Paris last week. He had planned to board the train from Cologne to Paris and since then he is missing! The last contact with his friends and family was made at the Cologne railway station.

Iran and US hostage exchange

Just a day after Iran and France exchanged hostage the Islamic Republic of Iran managed to force US releasing two of IRI spy’s held for a few years in Iraq. It does not take a rocket scientist to figure out that the release of Iranians in Iraq was an exchange with allowing the mothers of three arrested American hikers in Iran visiting their kids.