Hello. I'm trying to learn how to implement the Zend framework. Supposedly, this tutorial is compatable with the most recent stable version 0.9.0 beta, but I'm running into loads of conflicts.

Zend::loadClass() is deprecated so it tells me to use Zend_Loader::loadClass(). No problem except that it can't find the Zend_Loader class.

First things first, the directory structure is okay and the file DOES exist because I found it: 'library/Zend/Loader.php', and was able to get rid of the error by using
require_once(Zend/Loader.php)
BUT I would have to do this for each class file(!), so there is obviously a problem with my include path setting that I need to figure out.

The tutorial tells you to set up the directory structure as follows:

/root
|--/application
|--|--/controllers
|--|--/models
|--|--/views
|--/library
|--|--/Zend.php
|--|--/Zend
|--|--|--/Loader.php
|--|--|--/Registry.php
|--|--|--/a bunch of other stuff...
|--/public
|--|--/images
|--|--/scripts
|--|--/styles

This is the set_include_path it says to use:

set_include_path('.' . PATH_SEPARATOR . './library' . PATH_SEPARATOR . './application/models/' . PATH_SEPARATOR . get_include_path());
include("Zend.php");

but it can't find the classes:

Fatal Error: Class 'Zend_Loader' not found in c:\Webs\zf_tutorial\index.php

so what am I doing wrong?

    I did read in the manual (php.net) that set_include_paths is primarily used for php 4.3 whereas ini_set is used for later. Still having the same problem though. I've tried absolute and relative paths to the directories and it just won't find/recognize the classes.

    Anyone out there with ZF exoperience?

      I might suggest that you use .htaccess to set/extend the include path
      eg:
      php_value include_path ".:./library:./application/models/"

      Of course this is only an example, I doubt it will work as is but you get the idea.

        The trick is that you have to make sure Zend_Loader is included before calling any of the loadClass stuff. So make sure you have an include path pointed to
        ZendFramework/library and then do
        require_once 'Zend/Loader.php';

        You only do this include once in your bootstrap file. But again, you need to make sure that the ZendFramework/library directory is in your include path.

        In you example code you had "include Zend.php". Zend.php is no more. It's dead and has gone to meet it's maker. It is in fact an ex-file.

          Write a Reply...