« Return to Thread: ZF quickstart not working?

Re: ZF quickstart not working?

by Breen Liblong :: Rate this Message:

Reply to Author | View in Thread

Now I get as far as the bottom of the page Create a Model and Database Table, and when I browse to http://localhost/guestbook, I get the following error:

// application/models/Guestbook.php class Default_Model_Guestbook { protected $_comment; protected $_created; protected $_email; protected $_id; protected $_mapper; public function __construct(array $options = null) { if (is_array($options)) { $this->setOptions($options); } } public function __set($name, $value) { $method = 'set' . $name; if (('mapper' == $name) || !method_exists($this, $method)) { throw new Exception('Invalid guestbook property'); } $this->$method($value); } public function __get($name) { $method = 'get' . $name; if (('mapper' == $name) || !method_exists($this, $method)) { throw new Exception('Invalid guestbook property'); } return $this->$method(); } public function setOptions(array $options) { $methods = get_class_methods($this); foreach ($options as $key => $value) { $method = 'set' . ucfirst($key); if (in_array($method, $methods)) { $this->$method($value); } } return $this; } public function setComment($text) { $this->_comment = (string) $text; return $this; } public function getComment() { return $this->_comment; } public function setEmail($email) { $this->_email = (string) $email; return $this; } public function getEmail() { return $this->_email; } public function setCreated($ts) { $this->_created = $ts; return $this; } public function getCreated() { return $this->_created; } public function setId($id) { $this->_id = (int) $id; return $this; } public function getId() { return $this->_id; } public function setMapper($mapper) { $this->_mapper = $mapper; return $this; } public function getMapper() { if (null === $this->_mapper) { $this->setMapper(new Default_Model_GuestbookMapper()); } return $this->_mapper; } public function save() { $this->getMapper()->save($this); } public function find($id) { $this->getMapper()->find($id, $this); return $this; } public function fetchAll() { return $this->getMapper()->fetchAll(); } }
Fatal error: Class 'Default_Model_Guestbook' not found in /home/breen/tmp/zfproject/quickstart/application/controllers/GuestbookController.php on line 15

I've gone over all of the source to verify that I've made no typos, and it is defined as per the tutorial. But it seems to not know where to find it, and I can't figure out why.

Thanks very much for all your help.

Breen



That's the problem. I moved the data directory up a level (to peer with the application directory) and everything worked.

My error stemmed from an incorrect assumption that the data directory resided in the application directory, rather than in the parent (i.e. quickstart) directory.  Looking over the tutorial, I can see how I made the mistake, as the tutorial page, up to the mkdir data/db section, is all in the context of working in the application directory (or one of it's subdirs), and I misread the sentence "Note that the database(s) will be stored in data/db/." within that context.

I think it would have helped me to see a complete directory structure graph.  The one on the "Create Your Project" is great, but doesn't show the data directory (since it hasn't been created yet).

Thanks very much to all for your help in getting me over this doh! error.

Breen

Matthew Weier O'Phinney-3 wrote:
-- Mon Zafra <monzee@gmail.com> wrote
(on Thursday, 14 May 2009, 10:23 AM +0800):
> On Thu, May 14, 2009 at 10:03 AM, Breen Liblong <breen.liblong@shaw.ca> wrote:
>     OK, here's some additional information.
>
>     I'm working through the Zend Framework tutorial and have got to the Create
>     a
>     Model and Database Table section
>     (http://framework.zend.com/docs/quickstart/
>     create-a-model-and-database-table),
>     and am stuck at executing "php scripts/load.sqlite.php"
>
>     My configuration is
>     /home/breen/tmp/zfproject/quickstart/application/controllers
>     /home/breen/tmp/zfproject/quickstart/application/models
>     /home/breen/tmp/zfproject/quickstart/application/data  <<< emphasis mine
>     /home/breen/tmp/zfproject/quickstart/public/index.php
>     /home/breen/tmp/zfproject/quickstart/application/Bootstrap.php
>
> [snip]
>
>
>     The file
>     /home/breen/tmp/zfproject/quickstart/application/configs/application.ini
>     defines the database path as
>     ...
>     resources.db.params.dbname = APPLICATION_PATH "/../data/db/guestbook.db"
>     ...
>
>
> Shouldn't this be APPLICATION_PATH "/data/db/guestbook.db"? Since the data
> directory resides in the application directory.

Well, in the QuickStart, it's supposed to be as follows:

    application/
    data/
    public/

but clearly the OP didn't do that. If that's the case, then they need to
change their config accordingly, as you suggest.

--
Matthew Weier O'Phinney
Project Lead            | matthew@zend.com
Zend Framework          | http://framework.zend.com/

 « Return to Thread: ZF quickstart not working?