NOTES: Development is done in Netabean IDE, hosting is local on WAMPP, I have it configured for a virtual host. Composer is being used.
I have reviewed other questions similar to this and I do not have the same issue. Please note this is my first time using Zend framework. Thank you.
The use of echos helped me locate that when I create my AlbumTable in Module.php it fails.
Here is the Stacktrace:
[30-Mar-2015 20:29:11 Europe/Paris] PHP Fatal error: Class 'Album\Model\AlbumTable' not found in C:\wamp\www\quickstart\module\Album\Module.php on line 43
[30-Mar-2015 20:29:11 Europe/Paris] PHP Stack trace:
[30-Mar-2015 20:29:11 Europe/Paris] PHP 1. {main}() C:\wamp\www\quickstart\public\index.php:0
[30-Mar-2015 20:29:11 Europe/Paris] PHP 2. Zend\Mvc\Application->run() C:\wamp\www\quickstart\public\index.php:26
[30-Mar-2015 20:29:11 Europe/Paris] PHP 3. Zend\EventManager\EventManager->trigger() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php:313
[30-Mar-2015 20:29:11 Europe/Paris] PHP 4. Zend\EventManager\EventManager->triggerListeners() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:207
[30-Mar-2015 20:29:11 Europe/Paris] PHP 5. call_user_func:{C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:468}() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:468
[30-Mar-2015 20:29:12 Europe/Paris] PHP 6. Zend\Mvc\DispatchListener->onDispatch() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:468
[30-Mar-2015 20:29:12 Europe/Paris] PHP 7. Zend\Mvc\Controller\AbstractController->dispatch() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php:113
[30-Mar-2015 20:29:12 Europe/Paris] PHP 8. Zend\EventManager\EventManager->trigger() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractController.php:116
[30-Mar-2015 20:29:12 Europe/Paris] PHP 9. Zend\EventManager\EventManager->triggerListeners() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:207
[30-Mar-2015 20:29:12 Europe/Paris] PHP 10. call_user_func:{C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:468}() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:468
[30-Mar-2015 20:29:12 Europe/Paris] PHP 11. Zend\Mvc\Controller\AbstractActionController->onDispatch() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php:468
[30-Mar-2015 20:29:12 Europe/Paris] PHP 12. Album\Controller\AlbumController->indexAction() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php:83
[30-Mar-2015 20:29:12 Europe/Paris] PHP 13. Album\Controller\AlbumController->getAlbumTable() C:\wamp\www\quickstart\module\Album\src\Album\Controller\AlbumController.php:26
[30-Mar-2015 20:29:12 Europe/Paris] PHP 14. Zend\ServiceManager\ServiceManager->get() C:\wamp\www\quickstart\module\Album\src\Album\Controller\AlbumController.php:51
[30-Mar-2015 20:29:12 Europe/Paris] PHP 15. Zend\ServiceManager\ServiceManager->create() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:525
[30-Mar-2015 20:29:12 Europe/Paris] PHP 16. Zend\ServiceManager\ServiceManager->doCreate() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:593
[30-Mar-2015 20:29:12 Europe/Paris] PHP 17. Zend\ServiceManager\ServiceManager->createFromFactory() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:633
[30-Mar-2015 20:29:12 Europe/Paris] PHP 18. Zend\ServiceManager\ServiceManager->createServiceViaCallback() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:1057
[30-Mar-2015 20:29:12 Europe/Paris] PHP 19. call_user_func:{C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:923}() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:923
[30-Mar-2015 20:29:12 Europe/Paris] PHP 20. Album\Module->Album{closure}() C:\wamp\www\quickstart\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:923
Here is my 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 indexAction()
{
return new ViewModel(array(
'albums' => $this->getAlbumTable()->fetchAll(),
));
}
public function getAlbumTable()
{
echo "Made it";
if (!$this->albumTable) {
$sm = $this->getServiceLocator();
echo "Made it";
if($sm->has('Album\Model\AlbumTable'))
{
echo "FOUND Album\Model\AlbumTable";
$this->albumTable = $sm->get('Album\Model\AlbumTable');
}else{
echo "Could not find Album\Model\AlbumTable";
}
}
echo "Made it";
return $this->albumTable;
}
}
Here is Album\Module.php
namespace Album;
use Album\Model\Album;
use Album\Model\AlbumTable;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
class Module implements AutoloaderProviderInterface, ConfigProviderInterface
{
public function getAutoloaderConfig()
{
}
public function getConfig()
{
return include __DIR__ . '\config\module.config.php';
}
public function getServiceConfig()
{
return array(
'factories' => array(
'Album\Model\AlbumTable' => function($sm) {
// echo "inside ftn Album\Model\AlbumTable";
$tableGateway = $sm->get('AlbumTableGateway');
echo " Gate way GOOD";
$table = new AlbumTable($tableGateway);
echo "Table good";
return $table;
},
'AlbumTableGateway' => function ($sm) {
// echo "inside ftn AlbumTableGateway";
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
// echo "adapater good";
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Album());
return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
}
Here is Album\src\Album\Model\AlbumTable.php
namespace Album\Model;
use Zend\Db\TableGateway\TableGateway;
//use Zend\Db\ResultSet\ResultSet;
class AlbumTable
{
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
{
echo "inside construct of AlbumTable";
$this->tableGateway = $tableGateway;
}
I don't get inside of AlbumTable. I have included it in Module.php with use and the class name and files are spelled correctly. Unless my eyes fail me, and I hope that's the case.
Can anyone tell me why I am getting this error? My out put from the echos are as follows:
Made it Made it FOUND Album\Model\AlbumTable Gate way GOOD