Tag Archives: zend framework

Using the Zend framework with Symfony 1.4

In order to integrate Zend with your Symfony 1.4 project, follow these steps:

Step 1. Add the SplClassLoader class to your project (e.g., in /lib/autoload).

Step 2. Require the SplClassLoader and sfCoreAutoload.class.php (located in Symfony’s lib/autoload directory) in your projectConfiguration.class.php:

1
2
3
4
5
<?php
class projectConfiguration extends sfApplicationConfiguration{
       require_once dirname(__FILE__).'/usr/share/symfony/1.4.20/lib/autoload/sfCoreAutoload.class.php';
       require_once dirname(__FILE__).'/../lib/autoload/SplClassLoader.php';
       //...

Step 3. Then, copy the Zend framework to your project (e.g., to /lib/vendor/Zend) and add the following in your projectConfiguration.class.php:

1
2
3
4
5
6
7
8
9
10
<?php
class projectConfiguration extends sfApplicationConfiguration {
      //...
      public function configure(){
            //...
            sfCoreAutoload::register();
            $classLoader = new SplClassLoader('Zend', dirname(__FILE__).'/../../../lib/vendor');
            $classLoader->register();
      }
      //...

And it’s done! Now you can use namespaces to add Zend’s features to your Symfony project:

1
2
3
4
5
6
7
<?php
use Zend\Validator;
class myActions extends sfActions
{
  public function executeValidate(sfWebRequest $request){
    $validator = new EmailAddress();
    //...