default.php 6.9 KB

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