default.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. # 验证dc是否存在,一般在share目录下
  3. $dc = array();
  4. $dc_file = '/share/dc/config.php';
  5. if (is_file($dc_file)) {
  6. $dc = include($dc_file);
  7. }
  8. if (isset($dc['php'])) {
  9. $config['base']['php'] = $dc['php'];
  10. }
  11. if (isset($dc['data'])) {
  12. $config['base']['data'] = $dc['data'];
  13. }
  14. $create = false;
  15. if (isset($dc['mysql']['create'])) {
  16. $create = $dc['mysql']['create'];
  17. }
  18. //$create = true;
  19. $ip = isset($dc['host']) ? $dc['host'] : '192.168.33.10';
  20. $local = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $ip;
  21. # 数据库配置
  22. $config['database'] = array
  23. (
  24. 'create' => $create,
  25. # 默认数据库配置
  26. 'default' => array
  27. (
  28. 'type' => 'pdo',
  29. 'host' => array
  30. (
  31. 'read' => isset($dc['mysql']) ? $dc['mysql']['host'] : 'web-mysql:3306',
  32. 'update' => isset($dc['mysql']) ? $dc['mysql']['host'] : 'web-mysql:3306',
  33. 'create' => isset($dc['mysql']) ? $dc['mysql']['host_create'] : 'web-mysql:3306',
  34. ),
  35. 'database' => 'wonderful',
  36. 'username' => isset($dc['mysql']) ? $dc['mysql']['username'] : 'root',
  37. 'password' => isset($dc['mysql']) ? $dc['mysql']['password'] : '123456',
  38. 'charset' => 'utf8mb4',
  39. ),
  40. 'session' => array
  41. (
  42. 'type' => 'redis',
  43. 'host' => isset($dc['redis']) ? $dc['redis'][0]['host'] : 'server-redis',
  44. 'port' => isset($dc['redis']) ? $dc['redis'][0]['port'] : '6379',
  45. 'password' => isset($dc['redis']) ? $dc['redis'][0]['password'] : 'dm_redis_123',
  46. ),
  47. 'session1' => array
  48. (
  49. 'type' => 'memcache',
  50. 'host' => isset($dc['memcache']) ? $dc['memcache'][0]['host'] : 'server-memcached',
  51. 'port' => isset($dc['memcache']) ? $dc['memcache'][0]['port'] : '11211',
  52. 'password' => isset($dc['memcache']) ? $dc['memcache'][0]['password'] : '',
  53. )
  54. );
  55. /*
  56. $dc['mysql_user'] = array
  57. (
  58. 'host' => array
  59. (
  60. 'read' => 'web-mysql:3306',
  61. 'update' => 'web-mysql:3306',
  62. ),
  63. 'database' => 'wonderful',
  64. 'username' => 'root',
  65. 'password' => '123456',
  66. );
  67. */
  68. # 设置哪些项目需要切换到弹性数据库
  69. if (isset($dc['mysql_user'])) {
  70. $dc['mysql_user']['charset'] = 'utf8';
  71. $dc['mysql_user']['database'] = 'wonderful_act';
  72. $dc['mysql_user']['type'] = 'pdo';
  73. $config['database']['code'] = $dc['mysql_user'];
  74. $config['database']['act'] = $dc['mysql_user'];
  75. $config['database']['passport'] = $dc['mysql_user'];
  76. $config['database']['pay'] = $dc['mysql_user'];
  77. $config['database']['score'] = $dc['mysql_user'];
  78. $config['database']['message'] = $dc['mysql_user'];
  79. $config['database']['oauth'] = $dc['mysql_user'];
  80. $config['database']['wechat'] = $dc['mysql_user'];
  81. }
  82. if (DEVER_APP_NAME == 'tests' && isset($dc['mysql_test'])) {
  83. # 测试
  84. $dc['mysql_test']['charset'] = 'utf8';
  85. $dc['mysql_test']['database'] = 'wonderful_test';
  86. $dc['mysql_test']['type'] = 'pdo';
  87. $config['database']['default'] = $dc['mysql_test'];
  88. $config['database']['code'] = $dc['mysql_test'];
  89. $config['database']['act'] = $dc['mysql_test'];
  90. $config['database']['passport'] = $dc['mysql_test'];
  91. $config['database']['pay'] = $dc['mysql_test'];
  92. $config['database']['score'] = $dc['mysql_test'];
  93. $config['database']['message'] = $dc['mysql_test'];
  94. $config['database']['oauth'] = $dc['mysql_test'];
  95. $config['database']['wechat'] = $dc['mysql_test'];
  96. }
  97. # 缓存配置
  98. $config['cache'] = array
  99. (
  100. # 启用mysql数据库缓存,这个缓存是根据表名自动生成,dever::load形式和service的all、one形式均自动支持,无需手动添加
  101. 'mysql' => 0,
  102. # 启用页面缓存 会根据当前的url来生成缓存,相当于页面静态化。
  103. 'html' => 0,
  104. # 启用数据级别缓存 这个缓存是程序员自定义的:Dever::cache('name', 'value', 3600);
  105. 'data' => 1800,
  106. # 启用load加载器缓存,一般不加载
  107. 'load' => 0,
  108. # 启用load加载器的远程加载缓存
  109. 'curl' => 0,
  110. # 启用路由缓存
  111. 'route' => 1800,
  112. # 缓存精细控制,根据uri来控制,0则无需缓存
  113. 'routeKey' => array
  114. (
  115. 'journal.buy_action' => 0,
  116. 'journal.code' => 0,
  117. 'passport' => 0,
  118. 'oauth' => 0,
  119. 'cron' => 0,
  120. //'act' => 0,
  121. 'combine' => 0,
  122. 'service_' => 0,
  123. 'vip_' => 0,
  124. 'order.' => 0,
  125. 'pay.' => 0,
  126. 'buy_home' => 0,
  127. 'buy_my_code' => 0,
  128. 'buy_codedetail' => 0,
  129. 'buy.pay' => 0,
  130. 'journal_v1.top' => 600,
  131. 'journal_v1.subscribe' => 0,
  132. 'journal_v1.getView' => 0,
  133. //'journal_v1.getList' => 0,
  134. 'journal_v1.view' => 0,
  135. 'tests_api.user' => 0,
  136. 'tests_api.buy' => 0,
  137. 'stat_' => 0,
  138. 'buy_' => 0,
  139. 'order_' => 0,
  140. 'pay_' => 0,
  141. ),
  142. # 哪些路由中的参数不参与生成缓存的key
  143. 'routeNoParam' => array
  144. (
  145. 'signature' => array
  146. (
  147. 'content.home',
  148. 'content.news',
  149. 'content.up',
  150. 'content.ad',
  151. 'journal.home',
  152. 'journal.getList',
  153. 'journal_v1.home',
  154. 'journal_v1.getList',
  155. 'journal_v1.top',
  156. 'journal_v1.buy',
  157. 'journal_v1.read',
  158. 'journal_v1.getAppList',
  159. 'journal_v1.getView',
  160. 'journal_v1.getAppView',
  161. 'buy_list',
  162. 'buy_pay',
  163. ),
  164. 'uid' => array
  165. (
  166. 'content.home',
  167. 'content.news',
  168. 'content.up',
  169. 'content.ad',
  170. 'journal.home',
  171. 'journal.getList',
  172. 'journal_v1.home',
  173. 'journal_v1.getList',
  174. 'journal_v1.top',
  175. 'journal_v1.buy',
  176. 'journal_v1.read',
  177. 'journal_v1.getAppList',
  178. 'journal_v1.getView',
  179. 'journal_v1.getAppView',
  180. 'buy_list',
  181. 'buy_pay',
  182. ),
  183. ),
  184. # 缓存清理的参数名,请通过shell=clearcache执行
  185. 'shell' => 'clearcache',
  186. # 是否启用key失效时间记录,启用之后,将会记录每个key的失效时间
  187. 'expire' => true,
  188. # 缓存类型
  189. 'type' => 'redis',//memcache、redis
  190. # 缓存保存方式,支持多个数据源、多台缓存服务器
  191. 'store' => array
  192. (
  193. array
  194. (
  195. 'host' => 'server-redis',
  196. 'port' => '6379',
  197. 'weight' => 100,
  198. 'password' => 'dm_redis_123',
  199. ),
  200. ),
  201. );
  202. if (isset($dc['redis']) && $config['cache']['type'] == 'redis') {
  203. $config['cache']['store'] = $dc['redis'];
  204. }
  205. if (isset($dc['memcache']) && $config['cache']['type'] == 'memcache') {
  206. $config['cache']['store'] = $dc['memcache'];
  207. }
  208. $config['debug'] = array
  209. (
  210. 'log' => false
  211. );
  212. /*
  213. if (DEVER_APP_NAME == 'source') {
  214. $config['debug']['log'] = array('type' => 'file');
  215. }
  216. */
  217. $host = 'http://'.$local . '/';
  218. $upload = $host . 'upload/';
  219. $uploadcdn = $host . 'upload/data/';
  220. $config['host'] = array
  221. (
  222. 'upload'=> $upload . 'upload/?save',
  223. 'uploadRes' => isset($dc['res']) && $dc['res'] ? $dc['res'] : $uploadcdn . 'upload/',
  224. 'project' => array
  225. (
  226. 'upload' => array
  227. (
  228. 'path' => $host. 'upload/upload/?',
  229. ),
  230. 'pays' => array
  231. (
  232. 'path' => $host. 'pay/pay/?',
  233. ),
  234. 'wechat_applet' => array
  235. (
  236. 'path' => $host. 'wechat/wechat_applet/?',
  237. ),
  238. 'jingpin' => array
  239. (
  240. 'path' => 'http://192.168.33.10/jingpin/content/?'
  241. ),
  242. ),
  243. );
  244. return $config;