phalcon學習筆記-----名稱空間的使用
阿新 • • 發佈:2019-01-06
註冊名稱空間
$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;
});