誰かがこれを手伝ってくれることを願っています。
私はRobAllenのZendFramework2チュートリアルを進めています。
私が行こうとすると:
http://localhost/album/index
次のエラーが発生します。
[03-Sep-2012 17:48:07 UTC] PHP Fatal error: Class 'Album\AlbumTable' not found in C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\module\Album\Module.php on line 33
[03-Sep-2012 17:48:07 UTC] PHP Stack trace:
[03-Sep-2012 17:48:07 UTC] PHP 1. {main}() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\public\index.php:0
[03-Sep-2012 17:48:07 UTC] PHP 2. Zend\Mvc\Application->run() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\public\index.php:12
[03-Sep-2012 17:48:07 UTC] PHP 3. Zend\EventManager\EventManager->trigger() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php:298
[03-Sep-2012 17:48:07 UTC] PHP 4. Zend\EventManager\EventManager->triggerListeners() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:209
[03-Sep-2012 17:48:07 UTC] PHP 5. call_user_func() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:469
[03-Sep-2012 17:48:07 UTC] PHP 6. Zend\Mvc\DispatchListener->onDispatch() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:469
[03-Sep-2012 17:48:07 UTC] PHP 7. Zend\Mvc\Controller\AbstractController->dispatch() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php:114
[03-Sep-2012 17:48:07 UTC] PHP 8. Zend\EventManager\EventManager->trigger() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractController.php:108
[03-Sep-2012 17:48:07 UTC] PHP 9. Zend\EventManager\EventManager->triggerListeners() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:209
[03-Sep-2012 17:48:07 UTC] PHP 10. call_user_func() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:469
[03-Sep-2012 17:48:07 UTC] PHP 11. Zend\Mvc\Controller\AbstractActionController->onDispatch() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:469
[03-Sep-2012 17:48:07 UTC] PHP 12. Album\Controller\AlbumController->indexAction() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php:87
[03-Sep-2012 17:48:07 UTC] PHP 13. Album\Controller\AlbumController->getAlbumTable() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php:26
[03-Sep-2012 17:48:07 UTC] PHP 14. Zend\ServiceManager\ServiceManager->get() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\module\Album\src\Album\Controller\AlbumController.php:18
[03-Sep-2012 17:48:07 UTC] PHP 15. Zend\ServiceManager\ServiceManager->create() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:412
[03-Sep-2012 17:48:07 UTC] PHP 16. Zend\ServiceManager\ServiceManager->createFromFactory() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:455
[03-Sep-2012 17:48:07 UTC] PHP 17. Zend\ServiceManager\ServiceManager->createServiceViaCallback() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:801
[03-Sep-2012 17:48:07 UTC] PHP 18. call_user_func() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:684
[03-Sep-2012 17:48:07 UTC] PHP 19. Album\Module->Album\{closure}() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:684
AlbumTable.phpがAlbum\Modelにあるのに、クラス'Album\AlbumTable'が見つからないと言っていることに注意してください。
module \ Album \ Module.php:
<?php
// module/Album/Module.php
namespace Album;
class Module
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getServiceConfig()
{
return array(
'factories' => array(
'Album\Model\AlbumTable' => function($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$table = new AlbumTable($dbAdapter);
return $table;
},
),
);
}
}
module \ Album \ src \ Album \ Model \ AlbumTable.php:
<?php
// module/Album/src/Album/Model/AlbumTable.php:
namespace Album\Model;
use Zend\Db\Adapter\Adapter;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\AbstractTableGateway;
class AlbumTable extends AbstractTableGateway
{
protected $table ='album';
public function __construct(Adapter $adapter)
{
$this->adapter = $adapter;
$this->resultSetPrototype = new ResultSet();
$this->resultSetPrototype->setArrayObjectPrototype(new Album());
$this->initialize();
}
public function fetchAll()
{
$resultSet = $this->select();
return $resultSet;
}
public function getAlbum($id)
{
$id = (int) $id;
$rowset = $this->select(array('id' => $id));
$row = $rowset->current();
if (!$row) {
throw new \Exception("Could not find row $id");
}
return $row;
}
public function saveAlbum(Album $album)
{
$data = array(
'artist' => $album->artist,
'title' => $album->title,
);
$id = (int)$album->id;
if ($id == 0) {
$this->insert($data);
} else {
if ($this->getAlbum($id)) {
$this->update($data, array('id' => $id));
} else {
throw new \Exception('Form id does not exist');
}
}
}
public function deleteAlbum($id)
{
$this->delete(array('id' => $id));
}
}
module \ Album \ src \ Album \ Controller \ AlbumController.php:
<?php
// module/Album/src/Album/Controller/AlbumController.php:
namespace Album\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class AlbumController extends AbstractActionController
{
protected $albumTable;
public function getAlbumTable()
{
if (!$this->albumTable) {
$sm = $this->getServiceLocator();
$this->albumTable = $sm->get('Album\Model\AlbumTable');
}
return $this->albumTable;
}
public function indexAction()
{
return new ViewModel(array(
'albums' => $this->getAlbumTable()->fetchAll(),
));
}
public function addAction()
{
}
public function editAction()
{
}
public function deleteAction()
{
}
}
私の構成:
- Windows7。
- Zend Server CEテクノロジープレビュー(PHP 5.4)(Zend Server CE(PHP 5.3)を使用してみましたが、同じエラーが発生することに注意してください)。
- ApacheとMySQLは、他のPHPページでも正常に機能します。たとえば、単純なPHPスクリプトでPDOを使用して「アルバム」テーブルに接続できます。
問題が何であるかを知っている人はいますか?