Configuring Symfony to use Zend Framework 1.8.0 new Autoloader

Zend Framework 1.8.0 was released yesterday and if you are using it within a Symfony project, you need to know something:

Starting on 1.8.0 Zend_Load::autoload() is deprecated and will be removed on 2.0.0. So, before it is too late and you forget about it, you need to change the way Symfony uses Zend Framework. Remember that this change will work only with ZF 1.8.0 and above, so you need to make sure to upgrade to 1.8.0 before making the change.

The new way to configure your Symfony application to use Zend_Loader autoloader follows:

    if ($sf_zend_lib_dir = sfConfig::get('app_zend_lib_dir'))
    {
      set_include_path($sf_zend_lib_dir.PATH_SEPARATOR.get_include_path());
      require_once($sf_zend_lib_dir.'/Zend/Loader/Autoloader.php');
      spl_autoload_register(array('Zend_Loader_Autoloader', 'autoload'));
    }

01

05 2009
  • Take a look at sfToolkit::addIncludePath(). It includes a check to prevent paths from being added to the include path more than once.
blog comments powered by Disqus