default.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 = -1;
  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' => 'mars',
  36. 'username' => isset($dc['mysql']) ? $dc['mysql']['username'] : 'root',
  37. 'password' => isset($dc['mysql']) ? $dc['mysql']['password'] : '123456',
  38. 'charset' => 'utf8mb4',
  39. ),
  40. 'sessions' => 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. if (DEVER_APP_NAME == 'tests' && isset($dc['mysql_test'])) {
  56. # 测试
  57. $dc['mysql_test']['charset'] = 'utf8';
  58. $dc['mysql_test']['database'] = 'mars_test';
  59. $dc['mysql_test']['type'] = 'pdo';
  60. $config['database']['default'] = $dc['mysql_test'];
  61. $config['database']['code'] = $dc['mysql_test'];
  62. $config['database']['act'] = $dc['mysql_test'];
  63. $config['database']['passport'] = $dc['mysql_test'];
  64. $config['database']['pay'] = $dc['mysql_test'];
  65. $config['database']['score'] = $dc['mysql_test'];
  66. $config['database']['message'] = $dc['mysql_test'];
  67. $config['database']['oauth'] = $dc['mysql_test'];
  68. $config['database']['wechat'] = $dc['mysql_test'];
  69. }
  70. # 缓存配置
  71. $config['cache'] = array
  72. (
  73. # 启用mysql数据库缓存,这个缓存是根据表名自动生成,dever::load形式和service的all、one形式均自动支持,无需手动添加
  74. 'mysql' => 0,
  75. # 启用页面缓存 会根据当前的url来生成缓存,相当于页面静态化。
  76. 'html' => 0,
  77. # 启用数据级别缓存 这个缓存是程序员自定义的:Dever::cache('name', 'value', 3600);
  78. 'data' => 1800,
  79. # 启用load加载器缓存,一般不加载
  80. 'load' => 0,
  81. # 启用load加载器的远程加载缓存
  82. 'curl' => 0,
  83. # 启用路由缓存
  84. 'route' => 1800,
  85. # 缓存精细控制,根据uri来控制,0则无需缓存
  86. 'routeKey' => array
  87. (
  88. 'journal.buy_action' => 0,
  89. 'journal.code' => 0,
  90. 'passport' => 0,
  91. 'oauth' => 0,
  92. 'cron' => 0,
  93. //'act' => 0,
  94. 'combine' => 0,
  95. 'service_' => 0,
  96. 'vip_' => 0,
  97. 'order.' => 0,
  98. 'pay.' => 0,
  99. 'buy_home' => 0,
  100. 'buy_my_code' => 0,
  101. 'buy_codedetail' => 0,
  102. 'buy.pay' => 0,
  103. 'journal.top' => 600,
  104. 'journal.subscribe' => 0,
  105. 'journal.getView' => 0,
  106. //'journal.getList' => 0,
  107. 'journal.view' => 0,
  108. 'stat_' => 0,
  109. 'buy_' => 0,
  110. 'order_' => 0,
  111. 'pay_' => 0,
  112. ),
  113. # 哪些路由中的参数不参与生成缓存的key
  114. 'routeNoParam' => array
  115. (
  116. 'signature' => array
  117. (
  118. 'content.home',
  119. 'content.news',
  120. 'content.up',
  121. 'content.ad',
  122. 'journal.home',
  123. 'journal.getList',
  124. 'journal.top',
  125. 'journal.buy',
  126. 'journal.read',
  127. 'journal.getAppList',
  128. 'journal.getView',
  129. 'journal.getAppView',
  130. 'buy_list',
  131. 'buy_pay',
  132. ),
  133. 'uid' => array
  134. (
  135. 'content.home',
  136. 'content.news',
  137. 'content.up',
  138. 'content.ad',
  139. 'journal.home',
  140. 'journal.getList',
  141. 'journal.top',
  142. 'journal.buy',
  143. 'journal.read',
  144. 'journal.getAppList',
  145. 'journal.getView',
  146. 'journal.getAppView',
  147. 'buy_list',
  148. 'buy_pay',
  149. ),
  150. ),
  151. # 缓存清理的参数名,请通过shell=clearcache执行
  152. 'shell' => 'clearcache',
  153. # 是否启用key失效时间记录,启用之后,将会记录每个key的失效时间
  154. 'expire' => true,
  155. # 缓存类型
  156. 'type' => 'redis',//memcache、redis
  157. # 缓存保存方式,支持多个数据源、多台缓存服务器
  158. 'store' => array
  159. (
  160. /*
  161. array
  162. (
  163. 'host' => 'server-redis',
  164. 'port' => '6379',
  165. 'weight' => 100,
  166. 'password' => 'dm_redis_123',
  167. ),
  168. */
  169. ),
  170. );
  171. if (isset($dc['redis']) && $config['cache']['type'] == 'redis') {
  172. $config['cache']['store'] = $dc['redis'];
  173. }
  174. if (isset($dc['memcache']) && $config['cache']['type'] == 'memcache') {
  175. $config['cache']['store'] = $dc['memcache'];
  176. }
  177. $config['debug'] = array
  178. (
  179. 'log' => false
  180. );
  181. /*
  182. if (DEVER_APP_NAME == 'source') {
  183. $config['debug']['log'] = array('type' => 'file');
  184. }
  185. */
  186. $host = 'http://'.$local . '/';
  187. $upload = $host . 'mars/package/';
  188. $uploadcdn = $host . 'mars/data/';
  189. $config['host'] = array
  190. (
  191. 'upload'=> $upload . 'upload/?save',
  192. 'uploadRes' => isset($dc['res']) && $dc['res'] ? $dc['res'] : $uploadcdn . 'upload/',
  193. 'project' => array
  194. (
  195. 'wechat_applets' => array
  196. (
  197. 'path' => $host. 'wechat/wechat_applet/?',
  198. ),
  199. ),
  200. );
  201. return $config;