title: PHP Zend 2: Fatal Error - Class not found
body: <p>I'm trying to create own Model to do something (there will be calculations, moving in databases, and other non specifed work). But i got a problem, because I'm still getting and error that Class is not found.</p>
  
  <p>Here is controller (module/Application/src/Application/Controller/IndexController.php):</p>
  
  <pre><code>namespace Application\Controller;
  
  use Application\Model\Przesylki;
  use Zend\Mvc\Controller\AbstractActionController;
  use Zend\View\Model\ViewModel;
  
  class IndexController extends AbstractActionController
  {    
  
      public function indexAction()
      {
          $this-&gt;layout('layout/layout');
      }
  
      public function cennikAction() {
          $this-&gt;layout('layout/pusty');
          $logika_paczki = new Przesylki();
          echo $logika_paczki-&gt;return_word();
      }
  }
  </code></pre>
  
  <p>Module.php (module/Application/src/Module.php):</p>
  
  <pre><code>namespace Application;
  
  use Main\Model\Przesylki;
  
  class Module
  {
      const VERSION = '3.0.2dev';
  
      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';
      }
  }
  </code></pre>
  
  <p>and a model, Przesylki.php (module/Application/src/Application/Model/Przesylki.php):</p>
  
  <pre><code>namespace Main\Model;
  
  class Przesylki
  {
      public function return_word() {
          return "word";
      }
  }
  </code></pre>
  
  <p>if necessary, autoload_classmap.php (module/Application/src/autoload_classmap.php is just a </p>
  
  <pre><code>return array();
  </code></pre>
  
  <p>module.config.php:</p>
  
  <pre><code>namespace Application;
  
  use Zend\Router\Http\Literal;
  use Zend\Router\Http\Segment;
  use Zend\ServiceManager\Factory\InvokableFactory;
  
  return [
      'router' =&gt; [
          'routes' =&gt; [
              // Home
              'home' =&gt; [
                  'type' =&gt; Literal::class,
                  'options' =&gt; [
                      'route'    =&gt; '/',
                      'defaults' =&gt; [
                          'controller' =&gt; Controller\IndexController::class,
                          'action'     =&gt; 'counter',
                      ],
                  ],
              ],
              'work' =&gt; [
                  'type' =&gt; Literal::class,
                  'options' =&gt; [
                      'route'    =&gt; '/work',
                      'defaults' =&gt; [
                          'controller' =&gt; Controller\IndexController::class,
                          'action'     =&gt; 'index',
                      ],
                  ],
              ],
              'cennik' =&gt; [
                  'type' =&gt; Literal::class,
                  'options' =&gt; [
                      'route'    =&gt; '/cennik',
                      'defaults' =&gt; [
                          'controller' =&gt; Controller\IndexController::class,
                          'action'     =&gt; 'cennik',
                      ],
                  ],
              ],
              // Panel
              'panel' =&gt; [
                  'type'    =&gt; Segment::class,
                  'options' =&gt; [
                      'route'    =&gt; '/panel',
                      'defaults' =&gt; [
                          'controller' =&gt; Controller\PanelController::class,
                          'action'     =&gt; 'index',
                      ],
                  ],
              ],
              'test' =&gt; [
                  'type'    =&gt; Segment::class,
                  'options' =&gt; [
                      'route'    =&gt; '/panel/test',
                      'defaults' =&gt; [
                          'controller' =&gt; Controller\PanelController::class,
                          'action'     =&gt; 'test',
                      ],
                  ],
              ],
          ],
      ],
      'controllers' =&gt; [
          'factories' =&gt; [
              Controller\IndexController::class =&gt; InvokableFactory::class,
              Controller\PanelController::class =&gt; InvokableFactory::class,
          ],
      ],
      'view_manager' =&gt; [
          'display_not_found_reason' =&gt; true,
          'display_exceptions'       =&gt; true,
          'doctype'                  =&gt; 'HTML5',
          'not_found_template'       =&gt; 'error/404',
          'exception_template'       =&gt; 'error/index',
          'template_map' =&gt; [
              'layout/layout'           =&gt; __DIR__ . '/../view/layout/layout.phtml',
              'layout/panel'           =&gt; __DIR__ . '/../view/layout/panel_layout.phtml',
              'layout/counter'           =&gt; __DIR__ . '/../view/layout/counter.phtml',
              'layout/pusty'           =&gt; __DIR__ . '/../view/layout/pusty.phtml',
              'application/index/index' =&gt; __DIR__ . '/../view/application/index/index.phtml',
              'error/404'               =&gt; __DIR__ . '/../view/error/404.phtml',
              'error/index'             =&gt; __DIR__ . '/../view/error/index.phtml',
          ],
          'template_path_stack' =&gt; [
              __DIR__ . '/../view',
          ],
      ],
  ];
  </code></pre>
  
  <p>Directories:</p>
  
  <pre><code>/config
      /autoload
  /data
      /cache
  /module
      /Application
          /config
              module.config.php
          /src
              /Application
                  /Controller
                      IndexController.php
                      PanelController.php
                  /Model
                      Przesylki.php
              autoload_classmap.php
              Module.php
          /test
          /view
  /public
  </code></pre>
  
  <p>And when I run /cennik i got a Fatal, that class is not found:</p>
  
  <pre><code>[Tue Sep 06 08:58:20.446371 2016] [:error] [pid 4934] [client 195.8.99.234:1129] PHP Fatal error:  Class 'Main\\Model\\Przesylki' not found in /var/www/Paczucha_pl/module/Application/src/Main/IndexController.php on line 27
  </code></pre>
  
  <p>Actual files and namespaces:</p>
  
  <pre><code>Przesylki.php - Application\Model
  IndexController - Application\Controller
  PanelController - Application\Controller
  module.config.php - Application
  Module.php - Application
  </code></pre>