devilsansclue
devilsansclue

Reputation: 199

Class 'Shanty_Mongo_Document' not found

Trying to play with Shanty Mongo, and Zend (I am new to both) but I keep getting:

"Fatal error: Class 'Shanty_Mongo_Document' not found
    in /var/www/dbtz/application/models/User.php on line 4"

First, the indexAction of my controller:

public function indexAction()
{
    $this->view->pageTitle = "Add User";

    $form = new Application_Form_UserAdd();

    if ($this->_request->isPost()) {
        $formData = $this->_request->getPost();
        if ($form->isValid($formData)) {
            $user = new Application_Model_User();
            $user->username = $formData['username'];

            $user->save();
            exit;
        } else {
            $form->populate($formData);
        }
    }        

    $this->view->form = $form;
}

Second, the model:

class Application_Model_User extends Shanty_Mongo_Document
{
    protected static $_db = 'dbtz';
    protected static $_collection = 'user';

    public static $_requirements = array(
        'username' => 'Required',
        'password' => 'Required',
    );
}

I have the library/Shanty directory symlinked into the library folder. This is how I have the Zend library included, and it works fine.

tree of the library folder:

/var/www/dbtz/library# tree -l
.
├── Shanty -> /var/www/libs/Shanty-Mongo/library/Shanty/
│   ├── Mongo
│   │   ├── Collection.php
│   │   ├── Connection
│   │   │   ├── Group.php
│   │   │   └── Stack.php
│   │   ├── Connection.php
│   │   ├── Document.php
│   │   ├── DocumentSet.php
│   │   ├── Exception.php
│   │   ├── Iterator
│   │   │   ├── Cursor.php
│   │   │   └── Default.php
│   │   └── Validate
│   │       ├── Array.php
│   │       ├── Class.php
│   │       └── StubTrue.php
│   ├── Mongo.php
│   └── Paginator
│       └── Adapter
│           └── Mongo.php
└── Zend -> /usr/share/php/libzend-framework-php/Zend/
...

Upvotes: 1

Views: 220

Answers (1)

devilsansclue
devilsansclue

Reputation: 199

Figured it out. needed to add

autoloaderNamespaces[] = "Shanty_"

to my application.ini

Upvotes: 2

Related Questions