default.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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' => 7200,
  106. # 启用load加载器缓存,一般不加载
  107. 'load' => 0,
  108. # 启用load加载器的远程加载缓存
  109. 'curl' => 0,
  110. # 启用路由缓存
  111. 'route' => 7200,
  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. ),
  139. # 哪些路由中的参数不参与生成缓存的key
  140. 'routeNoParam' => array
  141. (
  142. 'signature' => array
  143. (
  144. 'content.home',
  145. 'content.news',
  146. 'content.up',
  147. 'content.ad',
  148. 'journal.home',
  149. 'journal.getList',
  150. 'journal_v1.home',
  151. 'journal_v1.getList',
  152. 'journal_v1.top',
  153. 'journal_v1.buy',
  154. 'journal_v1.read',
  155. 'journal_v1.getAppList',
  156. 'journal_v1.getView',
  157. 'journal_v1.getAppView',
  158. 'buy_list',
  159. 'buy_pay',
  160. ),
  161. 'uid' => array
  162. (
  163. 'content.home',
  164. 'content.news',
  165. 'content.up',
  166. 'content.ad',
  167. 'journal.home',
  168. 'journal.getList',
  169. 'journal_v1.home',
  170. 'journal_v1.getList',
  171. 'journal_v1.top',
  172. 'journal_v1.buy',
  173. 'journal_v1.read',
  174. 'journal_v1.getAppList',
  175. 'journal_v1.getView',
  176. 'journal_v1.getAppView',
  177. 'buy_list',
  178. 'buy_pay',
  179. ),
  180. ),
  181. # 缓存清理的参数名,请通过shell=clearcache执行
  182. 'shell' => 'clearcache',
  183. # 是否启用key失效时间记录,启用之后,将会记录每个key的失效时间
  184. 'expire' => true,
  185. # 缓存类型
  186. 'type' => 'redis',//memcache、redis
  187. # 缓存保存方式,支持多个数据源、多台缓存服务器
  188. 'store' => array
  189. (
  190. array
  191. (
  192. 'host' => 'server-redis',
  193. 'port' => '6379',
  194. 'weight' => 100,
  195. 'password' => 'dm_redis_123',
  196. ),
  197. ),
  198. );
  199. if (isset($dc['redis']) && $config['cache']['type'] == 'redis') {
  200. $config['cache']['store'] = $dc['redis'];
  201. }
  202. if (isset($dc['memcache']) && $config['cache']['type'] == 'memcache') {
  203. $config['cache']['store'] = $dc['memcache'];
  204. }
  205. $config['debug'] = array
  206. (
  207. 'log' => false
  208. );
  209. /*
  210. if (DEVER_APP_NAME == 'source') {
  211. $config['debug']['log'] = array('type' => 'file');
  212. }
  213. */
  214. $host = 'http://'.$local . '/';
  215. $upload = $host . 'upload/';
  216. $uploadcdn = $host . 'upload/data/';
  217. $config['host'] = array
  218. (
  219. 'upload'=> $upload . 'upload/?save',
  220. 'uploadRes' => isset($dc['res']) && $dc['res'] ? $dc['res'] : $uploadcdn . 'upload/',
  221. 'project' => array
  222. (
  223. 'upload' => array
  224. (
  225. 'path' => $host. 'upload/upload/?',
  226. ),
  227. 'pays' => array
  228. (
  229. 'path' => $host. 'pay/pay/?',
  230. ),
  231. 'wechat_applet' => array
  232. (
  233. 'path' => $host. 'wechat/wechat_applet/?',
  234. ),
  235. 'jingpin' => array
  236. (
  237. 'path' => 'http://192.168.33.10/jingpin/content/?'
  238. ),
  239. ),
  240. );
  241. return $config;