title: Rob Allen's Zend Framework 2 Tutorial: PHP Fatal error: Class 'Album\AlbumTable' not found
body: <p>I hope someone can help me with this.</p>
  
  <p>I am working my way through <a href="http://zf2.readthedocs.org/en/latest/user-guide/overview.html" rel="nofollow">Rob Allen's Zend Framework 2 Tutorial</a>.</p>
  
  <p>When I try to go to: </p>
  
  <pre><code>http://localhost/album/index
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>[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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;Album\{closure}() C:\Program Files (x86)\Zend\Apache2\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:684
  </code></pre>
  
  <p>Note it is saying <strong>Class 'Album\AlbumTable' not found</strong> even though AlbumTable.php is in Album\Model.</p>
  
  <p>module\Album\Module.php:</p>
  
  <pre><code>&lt;?php
  
  // module/Album/Module.php
  namespace Album;
  
  class Module
  {
      public function getAutoloaderConfig()
      {
          return array(
              'Zend\Loader\ClassMapAutoloader' =&gt; array(
                  __DIR__ . '/autoload_classmap.php',
              ),
              'Zend\Loader\StandardAutoloader' =&gt; array(
                  'namespaces' =&gt; array(
                      __NAMESPACE__ =&gt; __DIR__ . '/src/' . __NAMESPACE__,
                  ),
              ),
          );
      }
  
      public function getConfig()
      {
          return include __DIR__ . '/config/module.config.php';
      }
  
      public function getServiceConfig()
      {
          return array(
              'factories' =&gt; array(
                  'Album\Model\AlbumTable' =&gt;  function($sm) {
                      $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                      $table     = new AlbumTable($dbAdapter);
                      return $table;
                  },
              ),
          );
      }
  }
  </code></pre>
  
  <p>module\Album\src\Album\Model\AlbumTable.php:</p>
  
  <pre><code>&lt;?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-&gt;adapter = $adapter;
          $this-&gt;resultSetPrototype = new ResultSet();
          $this-&gt;resultSetPrototype-&gt;setArrayObjectPrototype(new Album());
          $this-&gt;initialize();
      }
  
      public function fetchAll()
      {
          $resultSet = $this-&gt;select();
          return $resultSet;
      }
  
      public function getAlbum($id)
      {
          $id  = (int) $id;
          $rowset = $this-&gt;select(array('id' =&gt; $id));
          $row = $rowset-&gt;current();
          if (!$row) {
              throw new \Exception("Could not find row $id");
          }
          return $row;
      }
  
      public function saveAlbum(Album $album)
      {
          $data = array(
              'artist' =&gt; $album-&gt;artist,
              'title'  =&gt; $album-&gt;title,
          );
          $id = (int)$album-&gt;id;
          if ($id == 0) {
              $this-&gt;insert($data);
          } else {
              if ($this-&gt;getAlbum($id)) {
                  $this-&gt;update($data, array('id' =&gt; $id));
              } else {
                  throw new \Exception('Form id does not exist');
              }
          }
      }
  
      public function deleteAlbum($id)
      {
          $this-&gt;delete(array('id' =&gt; $id));
      }
  }
  </code></pre>
  
  <p>module\Album\src\Album\Controller\AlbumController.php:</p>
  
  <pre><code>&lt;?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-&gt;albumTable) {
              $sm = $this-&gt;getServiceLocator();
              $this-&gt;albumTable = $sm-&gt;get('Album\Model\AlbumTable');
          }
          return $this-&gt;albumTable;
      }
  
      public function indexAction()
      {
          return new ViewModel(array(
              'albums' =&gt; $this-&gt;getAlbumTable()-&gt;fetchAll(),
          ));
      }
  
      public function addAction()
      {
      }
  
      public function editAction()
      {
      }
  
      public function deleteAction()
      {
      }
  }
  </code></pre>
  
  <p>My configuration:</p>
  
  <ul>
  <li>Windows 7.</li>
  <li>Zend Server CE Technology Preview (PHP 5.4) (Note I have tried using Zend Server CE (PHP 5.3) but get the same error). </li>
  <li>Apache and MySQL work fine for other PHP pages, e.g. I can connect to the 'album' table using PDO in a simple PHP script.</li>
  </ul>
  
  <p>Do any of you have any idea what the problem might be?</p>