Note that there are some explanatory texts on larger screens.

plurals
  1. POZF2: Zend framework 2.2 Controller not found error
    primarykey
    data
    text
    <p>I am trying to create new module in Zend Skeleton applictaion. I am following the Zend framework's getting started tutorial about Album module. Only difference is I am using Project name instead of Album. Here is my module structure.</p> <p><img src="https://i.stack.imgur.com/6p1XV.png" alt="module directory structure"></p> <p>The contents of <code>module.config.php</code> is as below.</p> <pre><code>&lt;?php namespace Project; return array( 'router' =&gt; array( 'routes' =&gt; array( 'project' =&gt; array( 'type' =&gt; 'segment', 'options' =&gt; array( 'route' =&gt; '/project[/:action][/:id]', 'contraints' =&gt; array( 'action' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*', 'id' =&gt; '[0-9]+' ), 'defaults' =&gt; array( 'controller' =&gt; __NAMESPACE__.'/Controller/'.__NAMESPACE__, 'action' =&gt; 'index' ) ) ) ) ), 'controllers' =&gt; array( 'invokables' =&gt; array( 'Project/Controller/Project' =&gt; 'Project/Controller/ProjectController', ) ), 'view_manager' =&gt; array( 'template_path_stack' =&gt; array( 'project' =&gt; __DIR__ . '../view', ) ), ); </code></pre> <p>Contents of <code>Module.php</code> is as below.</p> <pre><code>&lt;?php namespace Project; 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'; } } </code></pre> <p>The file <code>autoload_classmap.php</code> return only an empty array.</p> <pre><code>&lt;?php return array() </code></pre> <p>When I am trying to access the url <code>http://local.zf2/project/</code>, I get following error.</p> <pre><code>Fatal error: Class 'Project/Controller/ProjectController' not found in /home/bliss/public_html/local.zf2/vendor/zendframework/zendframework/library /Zend/ServiceManager/AbstractPluginManager.php on line 170 </code></pre> <p>When I looked at the <code>AbstractPluginManager.php</code> file the line 170 contains <code>$instance = new $invokable();</code>. </p> <p>I dumped <code>$invokable</code> variable to see the value it has. It returned <code>string(36) "Project/Controller/ProjectController"</code></p> <p>Somehow ZF2 is not able to find that file. Can some one please help? Thanks.</p> <p>EDIT: Here is the contents of <code>ProjectController.php</code> file. If it could find the file, it will die, showing the name of the file.</p> <pre><code>&lt;?php namespace Project\Controller; die(__FILE__); use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; class ProjectController extends AbstractActionController { public function indexAction() { return array(); // return new ViewModel(); } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload