phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.79k stars 1.96k forks source link

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

Closed applejohnny closed 11 years ago

applejohnny commented 11 years ago

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

phalcon commented 11 years ago

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' );
phongvt3110 commented 8 years ago

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