代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/RapPHP 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
namespace rap;
use rap\cache\CacheInterface;
use rap\cache\FileCache;
use rap\cache\RedisCache;
use rap\config\Config;
use rap\db\Connection;
use rap\db\MySqlConnection;
use rap\ioc\Ioc;
use rap\log\FileLog;
use rap\log\LogInterface;
use rap\storage\OssStorage;
use rap\storage\StorageInterface;
use rap\web\Application;
use rap\web\mvc\AutoFindHandlerMapping;
use rap\web\mvc\Router;
use rap\web\mvc\view\PhpView;
use rap\web\mvc\view\SmartyView;
use rap\web\mvc\view\TwigView;
use rap\web\mvc\view\View;
/**
* 南京灵衍信息科技有限公司
* User: jinghao@duohuo.net
* Date: 18/4/3
* Time: 下午2:26
*/
class RapApplication extends Application{
public function init( AutoFindHandlerMapping $autoMapping, Router $router){
$config=Config::getFileConfig();
$map=$config["mapping"];
if($map){
foreach ($map as $key=>$value) {
$autoMapping->prefix($key,$value);
}
}
$item=$config["db"];
if($item){
if($item['type']=='mysql'){
unset($item['type']);
Ioc::bind(Connection::class,MySqlConnection::class,function (MySqlConnection $connection)use($item){
$connection->config($item);
});
}
}
$item=$config["storage"];
if($item){
if($item['type']=='oss'){
unset($item['type']);
Ioc::bind(StorageInterface::class,OssStorage::class,function(OssStorage $ossStorage) use($item){
$ossStorage->config($item);
});
}
}
$item=$config["view"];
if($item){
if($item['type']=='smarty'){
unset($item['type']);
Ioc::bind(View::class,SmartyView::class,function(SmartyView $smartyView) use($item){
$smartyView->config($item);
});
}else if($item['type']=='php'){
unset($item['type']);
Ioc::bind(View::class,PhpView::class,function(PhpView $smartyView) use($item){
$smartyView->config($item);
});
}else if($item['type']=='twig'){
unset($item['type']);
Ioc::bind(View::class,TwigView::class,function(TwigView $smartyView) use($item){
$smartyView->config($item);
});
}
}
$item=$config["cache"];
if($item){
if($item['type']=='file'){
Ioc::bind(CacheInterface::class,FileCache::class,function(FileCache $fileCache) use($item){
$fileCache->config($item);
});
}elseif($item['type']=='redis'){
Ioc::bind(CacheInterface::class,RedisCache::class,function(RedisCache $redisCache )use($item){
$redisCache->config($item);
});
}
}
$item=$config["log"];
if($item){
if($item['type']=='file'){
Ioc::bind(LogInterface::class,FileLog::class,function(FileLog $fileLog )use ($item){
$fileLog->config($item);
});
}
}
$app= $config['app'];
if($app['init']){
Ioc::bind(Init::class,$app['init']);
/* @var $init Init */
$init=Ioc::get(Init::class);
$init->appInit($autoMapping,$router);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。