sasori Posted June 15, 2010 Share Posted June 15, 2010 here's the screenshot of the error here's the indexController code <?php class IndexController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $this->view->title = "My Albums"; $this->view->headTitle($this->view->title); $albums = new Application_Model_DbTable_Albums(); $this->view->albums = $albums->fetchAll(); } public function addAction() { // action body } public function editAction() { // action body } public function deleteAction() { // action body } } here's the albums.php model class (the alleged missing class ? ) <?php class Application_Model_DbTable_Albums extends Zend_Db_Table_Abstract { protected $_name = 'albums'; public function getAlbum($id) { $id = (int)$id; $row = $this->fetchRow('id = '. $id); if(!$row) { throw new Exception("Could not find row $id"); } return $row->toArray(); } public function addAlbum($artist,$title) { $data = array( 'artist'=>$artist, 'title'=>$title ); $this->insert($data); } public function updateAlbum($id,$artist,$title) { $data = array( 'artist'=>$artist, 'title'=>$title ); $this->update($data,'id = '.(int)$id); } public function deleteCd($id) { $this->delete('id = '.(int)$id); } } ?> here's the view of index.phtml <p><a href="<?php echo $this->url(array('controller'=>'index','action'=>'add'));?>"> Add new album</a></p> <table> <tr> <th>Title</th> <th>Artist</th> <th> </th> </tr> <?php foreach($this->albums as $album): ?> <tr> <td><?php echo $this->escape($album->title);?></td> <td><?php echo $this->escape($album->artist);?></td> <td> <a href="<?php echo $this->url(array( 'controller'=>'index', 'action'=>'edit', 'id'=>$cd->id));?>">Edit</a> <a href="<?php echo $this->url(array( 'controller'=>'index', 'action'=>'delete', 'id'=>$album->id));?>">Delete</a> </td> </tr> <?php endforeach;?> </table> and here's the screenshot of the folder structures I don't know why the hell it's giving me that error, am just following the akrabat's tutorial on zend framework 1.10 Quote Link to comment https://forums.phpfreaks.com/topic/204824-class-missing-please-help/ Share on other sites More sharing options...
trq Posted June 15, 2010 Share Posted June 15, 2010 Is application/models on your include path ? Quote Link to comment https://forums.phpfreaks.com/topic/204824-class-missing-please-help/#findComment-1072295 Share on other sites More sharing options...
sasori Posted June 15, 2010 Author Share Posted June 15, 2010 this is what i have in the public/index.php file <?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(); is that where the application/models should exists ? or you're referring to a different thing ? Quote Link to comment https://forums.phpfreaks.com/topic/204824-class-missing-please-help/#findComment-1072299 Share on other sites More sharing options...
trq Posted June 15, 2010 Share Posted June 15, 2010 Its been a long while since I've used Zend and there could be a more standard way of doing it but, if you want your Models directory on your path you need to add it. set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library'), realpath(APPLICATION_PATH . '/Model'), get_include_path(), ))); Also, your models directory should be named Model and the albums.php file should be named Albums.php Quote Link to comment https://forums.phpfreaks.com/topic/204824-class-missing-please-help/#findComment-1072323 Share on other sites More sharing options...
sasori Posted June 15, 2010 Author Share Posted June 15, 2010 it didn't help..still Fatal error: Class 'Application_Model_DbTable_Albums' not found in C:\xampp\htdocs\zf\zf-tutorial\application\controllers\IndexController.php on line 16 Quote Link to comment https://forums.phpfreaks.com/topic/204824-class-missing-please-help/#findComment-1072350 Share on other sites More sharing options...
ignace Posted June 15, 2010 Share Posted June 15, 2010 Register the namespace Application_ and it's path with the Loader, you can do this within your configuration file. http://framework.zend.com/manual/en/zend.application.core-functionality.html autoloaderNamespaces.Application_ = "library/Application/" Quote Link to comment https://forums.phpfreaks.com/topic/204824-class-missing-please-help/#findComment-1072509 Share on other sites More sharing options...
Cagecrawler Posted June 15, 2010 Share Posted June 15, 2010 You should look up resource autoloaders. You'll need to register Application as a resource namespace like so: $resourceLoader = new Zend_Loader_Autoloader_Resource(array( 'basePath' => 'path/to/application', 'namespace' => 'Application', )); The code should go into your bootstrap class (assuming you're using Zend_Application). Quote Link to comment https://forums.phpfreaks.com/topic/204824-class-missing-please-help/#findComment-1072705 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.