Php 类别';Shanty_Mongo_文件';找不到
尝试与Shanty Mongo和Zend(我对他们都是新手)一起玩,但我一直得到:Php 类别';Shanty_Mongo_文件';找不到,php,zend-framework,mongodb,Php,Zend Framework,Mongodb,尝试与Shanty Mongo和Zend(我对他们都是新手)一起玩,但我一直得到: "Fatal error: Class 'Shanty_Mongo_Document' not found in /var/www/dbtz/application/models/User.php on line 4" 首先,我的控制器的索引: public function indexAction() { $this->view->pageTitle = "Add User";
"Fatal error: Class 'Shanty_Mongo_Document' not found
in /var/www/dbtz/application/models/User.php on line 4"
首先,我的控制器的索引:
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;
}
第二,模式:
class Application_Model_User extends Shanty_Mongo_Document
{
protected static $_db = 'dbtz';
protected static $_collection = 'user';
public static $_requirements = array(
'username' => 'Required',
'password' => 'Required',
);
}
我已将library/Shanty目录符号链接到library文件夹中。这就是我包含Zend库的方式,它工作得很好
库文件夹的目录树:
/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/
...
我明白了。需要添加
autoloaderNamespaces[] = "Shanty_"
对于我的应用程序.ini来说,我对Zend不太熟悉,但是你能暂时挂接到autoloader系统,看看它在哪里查找类文件吗?你安装了php驱动程序吗?()确保已将库文件放置在正确的位置place@nixy是的,我已经安装了mongo php驱动程序。