Hello Jon I have some problem with 'models'. I am including the the model path but still my
program is not identifying the class ,which I stored in 'models'. Can you solve it for me and tell me why it is or was not identifying my 'models' folder.
This is my Folder structure
/application
/configs
-application.ini
/controllers
-ErrorController.php
-IndexController.php
/layouts
-layout.phtml
/forms
/models
-Test.php
/views
/helpers
/scripts
/error
-error.phtml
/index
-index.phtml
-Bootstrap.php
/library
/Zend
/public
-index.php
-.htaccess
----------------------------------------------
[ index.php : Script ]
----------------------------------------------
<?php
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/models'),
get_include_path(),
)));
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()->run();
-------------------------------------------------
[ Bootstrap.php : Script ]
-------------------------------------------------
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
return $moduleLoader;
}
protected function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
}
}
---------------------------------------------------
[ application.ini : script ]
---------------------------------------------------
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
includePaths.models = APPLICATION_PATH "/models"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutpath = APPLICATION_PATH "/layouts"
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = root
resources.db.params.dbname = zend_test
---------------------------------------------------
[ Test.php : script ]
---------------------------------------------------
<?php
class Test extends Zend_Db_Table_Abstract
{
protected $_name = 'testing';
}
?>
--------------------------------------------------
[ IndexController.php : script ]
--------------------------------------------------
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$user = new Test(); // Line 6
}
}
----------------------
The Output is
----------------------
Fatal error: Class 'Test' not found in C:\www\sandbox\zendtest\application\controllers\IndexController.php on line 6
PLEASE HELP ME TO FIND FAULT WHICH I HAVE DONE IN MY PROGRAM
Last edited by smriti (2009-12-16 08:17:25)