注册命名空间
$loader = new \Phalcon\Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerDirs(
[
$config->application->controllersDir,
$config->application->modelsDir
]);
$loader->registerNamespaces([
'App\Models' => APP_PATH . '/models/',
'App\Library' => APP_PATH . '/common/library/',
'App\Controllers' => APP_PATH . '/controllers/',
]);
$loader->register();
设置默认使用的命名空间
$di->set('dispatcher', function () {
$dispatcher = new \Phalcon\Mvc\Dispatcher();
$dispatcher->setDefaultNamespace("App\\Controllers");
return $dispatcher;
});