Autoloading issues with 5.3 namespaces

I’ve registered a Doctrine 2 class loader via Yii::registerAutoloader for the Doctrine 2 library and my own library situated in a new directory outside of the protected directory called ‘vendor’.



  - index.php

  - etc.


  - Doctrine

  - Application (my library)


I have created a class inside my application that extends CHttpRequest so that I can write to a MongoDB store. It is namespaced Application\Session\MongoDbSession. I have also extends CWebUser to Application\User. In my main.php config, I have made the following settings;

Yii::setPathOfAlias('vendor', VENDOR_DIR);

Yii::setPathOfAlias('Application', VENDOR_DIR . '/Application');


'session' => array(

    'class'    => 'Application\Session\MongoDbSession',

    'document' => 'Application\Documents\Session',

    'dm'       => 'default',




    'class'          => 'Application\User',

    'allowAutoLogin' => true,


Now with all that configured, I am instantiating a new object inside of the MongoDbSession::writeSession;

public function writeSession($id,$data)


    var_dump(new \Application\Documents\Session);


From a controller, I am testing itby calling Yii::app()->session->writeSession(‘foo’, ‘bar’). The new object is instantiated correctly. If however, I call Yii::app()->user->setState(‘foo’, ‘bar’), a PHP fatal error is thrown stating it cannot load the class - this error is not caught by Yii.

Am I setting up the autoloader correctly? Is there something missing in the config?

I’ve traced where the exact error is getting thrown. It is in CHttpSession::open where session_set_save_handler is being invoked. A work around is by overrideing the method in my class and creating a new object and passing to the callback array’s;

public function open()


    $object = get_class($this);

    $object = new $object;

    if($this->getUseCustomStorage()) {











This seem a bit of a hack. Is this a PHP 5.3 bug??