default.php 7.2 KB

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