我正试图找出我的第一个教程的问题,使用Zend骨架应用程序。我正在使用ZendServer 10 +ZendServer和Zf2.2;设法使框架应用程序正常工作,现在遇到了一个缺失的类问题(参见下面的错误)。我尝试过各种方法,但结果是一样的:--它不工作。这是我的档案,任何帮助都将不胜感激。
我的错误:
致命错误:在第55行的C:\ProgramFiles\Zend\Apache2\htdocs\zf2album\module\Album\Module.php中找不到类‘相册\型号\白蛋白表’
相册/Module.php
命名空间相册; 使用相册\模型\相册; 使用相册\模型\白蛋白表; 使用Zend\Db\TableGateway\TableGateway; 使用Zend\ModuleManager\Feature\ServiceProviderInterface; 类模块实现ServiceProviderInterface { 公共函数getAutoloaderConfig() {返回数组( 'Zend\Loader\ClassMapAutoloader‘=>数组( __DIR__ )。'/autoload_classmap.php',),'Zend\Loader\StandardAutoloader‘=>数组(’名称空间‘=>数组( //如果我们位于一个比一个级别更深的名称空间中,我们需要修复路径__NAMESPACE__ => __DIR__中的\)。“/src/”str_replace('\','/‘,__NAMESPACE__),),);}公共函数getConfig() {返回包含__DIR__。'/config/module.config.php';} //添加此方法:公共函数getServiceConfig() {返回数组(‘工厂’=>数组)(‘相册\模型\白蛋白表’=>函数($sm){ $tableGateway = $sm->get('AlbumTableGateway');$table =新AlbumTable($tableGateway);返回$table;},'AlbumTableGateway‘=>函数($sm) { $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');$resultSetPrototype =新ResultSet();$dbAdapter相册();返回新TableGateway(’相册‘,$dbAdapter,null,$resultSetPrototype);},);}
the AlbumController.php
名称空间相册\控制器; 使用Zend\Mvc\Controller\抽象动作控制器;使用Zend\View\Model\ViewModel; 类AlbumController扩展了AbstractActionController {受保护的$albumTable; 公共函数indexAction() {返回新的ViewModel(数组(‘相册’=> $ This ->getAl保险表()->fetchAll(),));}公共函数addAction() {}公共函数editAction() {}公共函数deleteAction() {}公共函数fooAction() { //这将显示默认路由/在浏览/相册/相册/foo返回数组()时:控制器和:action参数正在工作;}公共函数getAlbumTable() { if (! $this->albumTable ) { $sm = $this->getServiceLocator();$this->al保险杠表=$sm->get(‘相册\模型\白蛋白表’);}返回$this->albumTable;}}
AlbumModel.php
名称空间相册\模型; 使用Zend\Db\TableGateway\TableGateway; 类AlbumTable {受保护的$tableGateway; 公共函数__construct(TableGateway $tableGateway) { $this->tableGateway = $tableGateway;}公共函数fetchAll() { $resultSet = $this->tableGateway->select();返回$resultSet;}公共函数getAlbum( $id ) {$id= (int) $id;$rowset =$this->tableGateway->select(数组(‘id’=> $id));$row = $rowset->current();if (!$row) {抛出新的\异常(“无法找到行$id");}返回$row;}公共函数saveAlbum( $album) { $data =$data(‘=>’>相册->艺术家,'title‘=> $相册->标题,’$id =(Int)$相册->id;if ($id == 0) {$this->tableGateway->插入($data );} => { if ($this->getAlbum($id)) {$此->表网关->更新($data,数组(‘id’=> $id));}公共函数deleteAlbum($id) {$this->tableGateway->delete(数组(‘id’=> $id));}
发布于 2013-05-23 14:45:25
假设这不是您问题中的错误,那么类AlbumTable的文件名应该是AlbumTable.php,而不是AlbumModel.php。
https://stackoverflow.com/questions/16716721
复制相似问题