cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Dispatcher can't load Controller with additional namespace while using short syntax in router

Open applejohnny opened this issue 13 years ago • 2 comments

This code

$router->add(
    '/api/folder-list',
    [
        'controller' => 'Api\Folder',
        'action' => 'list'
    ]
)
    ->setName( 'api-folder-list' );

works fine, but this

$router->add(
    '/api/folder-list', 'Api\Folder::list'
)
    ->setName( 'api-folder-list' );

throws Phalcon\Mvc\Dispatcher\Exception with message 'Mail\Controllers\api\folderController handler class cannot be loaded' .

Version 0.8

applejohnny avatar Jan 16 '13 14:01 applejohnny

Hi Bekin, the namespace must be passed as a different parameter as explained here: http://docs.phalconphp.com/en/latest/reference/routing.html#routing-to-modules

$router->add('/api/folder-list', [
   'namespace' => 'Api\\',
   'controller' => 'folder',
   'action' => 'list'
])->setName( 'api-folder-list' );

ghost avatar Jan 16 '13 18:01 ghost

hi everyone,i downloaded HMVC phalcon from github and i ran it but i get this error after i ran composer install --no-dev command,i ran successfully phalcon framework with no HMVC but i want to try HMVC . The error i got below

Phalcon\Mvc\Dispatcher\Exception: IndexController handler class cannot be loaded File=/var/www/PhalconHMVC/public/index.php Line=28 #0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('IndexController...', 2) #1 [internal function]: Phalcon\Dispatcher->_dispatch() #2 [internal function]: Phalcon\Dispatcher->dispatch() #3 /var/www/PhalconHMVC/public/index.php(28): Phalcon\Mvc\Application->handle() #4 {main}

Can anyone tell me how to fix this error or how to run HMVC phalcon , i don't know how to run Hello world HMVC phalcon . Thanks advance

phongvt3110 avatar Aug 15 '16 01:08 phongvt3110