Symfony

Symfony2 and SQLite3 or PDO_SQLite extension error

If you are getting  

You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly

To resolved it install the php5-sqlite

sudo apt-get install php5-sqlite
#restart the apache
sudo /etc/init.d/apache2 restart

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) {
    pre( print_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