基于phalcon框架单模块 Model 扩展 Logic中间层

分享 0 1259
寳唄 小猫
寳唄 小猫   会员 发布于:17个月前
悬赏:60飞吻
基于phalcon框架单模块 Model 扩展 Logic中间层

框架目录:


config 里面配置如下:
return new \Phalcon\Config(array(
'database' => array(
'adapter' => 'Mysql',
'host' => '',
'username' => '',
'password' => '',
'dbname' => '',
'charset' => '',
),
'application' => array(
'controllersDir' => APP_PATH . '/app/controllers/',
'modelsDir' => APP_PATH . '/../base/models/',
'libraryDir' => APP_PATH . '/../base/library/',
'migrationsDir' => APP_PATH . '/app/migrations/',
'viewsDir' => APP_PATH . '/app/views/',
'pluginsDir' => APP_PATH . '/app/plugins/',
'cacheDir' => APP_PATH . '/app/cache/',
'logicDir' => APP_PATH . '/app/logic/',
'baseUri' => '/',
),
//queue
'beanstalk' => array(
'host' => '',
'port' => '',
'persistent' =>
),
'proxy_ips' => array(
''
),
//redis
'redis' => array(
'host' => '',
'port' => '',
//'auth' => '',
//'auth' =>'',
'persistent' => false,
'index'=>0
),
"redis_other_prefix"=>array(

),
));

loader.php:

$loader = new \Phalcon\Loader();
$loader->registerDirs(
array(
$config->application->controllersDir,
$config->application->modelsDir,
$config->application->libraryDir,
$config->application->logicDir,
)
)->register();

$loader->registerNamespaces(array(
'Logic' => $config->application->logicDir,
))->register();

调用:

在Logic 目录下新建 BookingClassLogic

namespace Logic;
class BookingClassLogic extends LogicBase
{
public function getBookById(){
........
}
}



控制器里调用:
<?php
use \Logic\BookingClassLogic as BookingClassLogic;
class BookingController extends ControllerBase{
public function indexAction(){
$BoookingClassLogic = new BookingClassLogic();
$newData = $BoookingClassLogic->getBookById();
}
}


回帖
  • 暂时没有人回复,你来做第一个吧

寳唄 小猫 会员

2017-12-12 加入 来自中国

(这个人懒得留下签名)

活跃榜
大家好像都不是很活跃
本周热门
本周暂无热帖