Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

ResourceController handler class cannot be loaded

LOADER CODE

<?php

$loader = new \Phalcon\Loader();

$loader->registerNamespaces(
    array(
        'Site\Front\Controller'         =>  __DIR__ . '/../../app/controllers/',
        'Site\Model'                    =>  __DIR__ . '/../../app/models/',
    )
)->register();

CONTROLLER CODE

namespace Site\Front\Controller;

Use Site\Library\Form\Resource;

class resourceController extends ControllerBase  {

    public function indexAction()
    {
        echo 'in';
        // New Form
        //$objForm =  new Resource\NewForm();
        //$this->view->setVar('newForm', $objForm->createForm());
    }


    // Add New Resource
    public function addAction()
    {
        $strResource = $this->request->getPost('url', 'string');

        // Creating Form
        $objForm = new Resource\SubmitForm();
        $this->Tag->setDefault('urlName', $strResource);
        $this->view->setVar('addForm', $objForm->createForm());
    }
}

Why is the controller not loading?



1.4k
edited Jul '14

I think you do not register all the namespaces e.g: Site\Library\Form



84.5k

Try changing the class name from resourceController to ResourceController



14.9k

I renamed 'resourceController' to 'ResourceController' still same result.



84.5k

Can you post your code somewhere? Like on Github?



14.9k
edited Jul '14

Here is my code

Bootsrap-

<?php

error_reporting(E_ALL);

//(new Phalcon\Debug())->listen();

//try {

    /**
     * Read the configuration
     */
    $config = include __DIR__ . "/../app/config/config.php";

    /**
     * Read auto-loader
     */
    include __DIR__ . "/../app/config/loader.php";

    /**
     * Read services
     */
    include __DIR__ . "/../app/config/services.php";

    /**
     * Handle the request
     */
    $application = new \Phalcon\Mvc\Application($di);

    echo $application->handle()->getContent();

/*} catch (\Exception $e) {
    echo $e->getMessage();
}*/

Loader and controller code are posted above



14.9k
Accepted
answer

Thansk for your responses.

I have found the cause of the problem. It is NAMESPACE defination. I did not setup the "$dispatcher->setDefaultNamespace('Site\Front\Controller');"