Internal server 500 error help with calling class

For programming and general questions on Zend Framework

Internal server 500 error help with calling class

Postby skoobi on Sat Nov 05, 2011 11:59 am

Hi im new to the zend framework but im slowly getting there... :) ...
Im currently running throught the 'Pro zend framework techniques' book but ive hit a snag which im not quite sure where to look...
The error from the php error log is:
[05-Nov-2011 10:51:53] PHP Fatal error: Class 'Model_Bug' not found in C:\Program Files (x86)\Zend\Apache2\htdocs\zfcms\application\controllers\BugController.php on line 12

which is:
$bugModel = new Model_Bug();

Code: Select all
   public function submitAction()
    {
        $bugReportForm = new Form_BugReportForm();
        $bugReportForm->setAction('/bug/submit');
        $bugReportForm->setMethod('post');
        if ($this->getRequest()->isPost()) {
            if ($bugReportForm->isValid($_POST)) {
                $bugModel = new Model_Bug();
                // if the form is valid then create the new bug
                $result = $bugModel->createBug(
                $bugReportForm->getValue('author'),
                $bugReportForm->getValue('email'),
                $bugReportForm->getValue('date'),
                $bugReportForm->getValue('url'),
                $bugReportForm->getValue('description'),
                $bugReportForm->getValue('priority'),
                $bugReportForm->getValue('status')
                );
                // if the createBug method returns a result
                // then the bug was successfully created
                if ($result) {
                    $this->_forward('confirm');
                }
            }
        }
        $this->view->form = $bugReportForm;
    }


But what im not sure about is why isnt it calling the class ...

Any help or tips would be greatful...

Cheers
Chris
skoobi
 
Posts: 1
Joined: Sat Oct 08, 2011 9:47 am

Re: Internal server 500 error help with calling class

Postby clintlenard on Sat Jan 21, 2012 4:48 am

This is old, but I came across this by accident while going through this book. The OP left out Application_. The correct model class name is:

Application_Model_Bug

Just figured I'd reply in case someone else comes across this problem.
clintlenard
 
Posts: 1
Joined: Sat Jan 21, 2012 4:46 am

Re: Internal server 500 error help with calling class

Postby jschoenwolf on Sat Jan 21, 2012 9:30 am

Be careful with this book, the version of ZF used was 1.8 I think (I'm working through the book myself). There have been some changes to ZF since then making some of his code obsolete, though it should still work. The actual information is great, but be careful of code mistakes I've spotted several.

Model_Bug should actually be Application_Model_DbTable_Bug because it is a Zend_Db_Table_Abstract class but Application_Model_Bug will work if you use the bootstrap autoloading he suggests (That kind of autoloading is no longer required if you use the ZF defaults).

If you are as new as say you might want to start with something a little more current so you can spot where you need to make changes.
Here a re two suggestions that are free:
http://akrabat.com/zend-framework-tutorial/, http://survivethedeepend.com/
jschoenwolf
 
Posts: 239
Joined: Tue Aug 23, 2011 10:56 am


Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 9 guests