Zend Framework 1.10 custom Class inside library fo

2019-08-27 23:07发布

问题:

I'm learning zend framework from zendCast and can't find the problem

I'm using:

-Zend Server CE

-Zend Studio 7.2

-Zend Framework 1.10 (created with zend studio)

In my library folder I have a folder App and in that folder a php file Countries.php which corresponds to App_Countries class but when I try to create a new App_Countries object it says that class could not be loaded any ideas on how to get rid of the error?

Fatal error: Class 'App_Countries' not found in /usr/local/zend/apache2/htdocs/ZC/application/controllers/IndexController.php on line 14

index.php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();

回答1:

Make sure the autoloadernamespace is properly configured in your application.ini.
It should contain something like this:

autoloadernamespaces[] = "Zend"
autoloadernamespaces[] = "App"