apphtml5.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. /**
  10. * 本文件在@apphtml5/web/index.php 处,会被引入。
  11. * 该配置文件会加载./modules/*.php,并合并成一个数组,返回。
  12. */
  13. $modules = [];
  14. foreach (glob(__DIR__ . '/modules/*.php') as $filename) {
  15. $modules = array_merge($modules, require($filename));
  16. }
  17. $params = require __DIR__ .'/params.php';
  18. // 此处也可以重写fecshop的组件。供调用。
  19. $config = [
  20. 'modules'=>$modules,
  21. /**
  22. * bootstrap指的是yii2中的初始化(注意,这个bootstrap不是css那个bootstrap),关于Yii2 bootstrap的功能描述可以
  23. * 参看地址:http://www.yiichina.com/doc/guide/2.0/runtime-bootstrapping
  24. *
  25. * 下面的配置的作用为:在fecshop初始化的时候,执行store component的bootstrap方法。
  26. * 也就是 @fecshop/components/Store.php的bootstrap($app)函数。
  27. * 最终是Yii::$service->store->bootstrap($app); 这样,无论执行任何controller,都会执行该函数
  28. * 这也就是bootstap的作用,在Yii2初始化的时候执行的部分代码。
  29. */
  30. 'bootstrap' => ['store'],
  31. // 参数配置部分
  32. 'params' => $params,
  33. // Yii组件配置 ,关于yii2组件,可以参看:http://www.yiichina.com/doc/guide/2.0/structure-application-components
  34. 'components' => [
  35. // yii2 语言组件配置,关于Yii2国际化,可以参看:http://www.yiichina.com/doc/guide/2.0/tutorial-i18n
  36. 'i18n' => [
  37. 'translations' => [
  38. 'apphtml5' => [
  39. //'class' => 'yii\i18n\PhpMessageSource',
  40. 'class' => 'fecshop\yii\i18n\PhpMessageSource',
  41. 'basePaths' => [
  42. '@fecshop/app/apphtml5/languages',
  43. ],
  44. ],
  45. ],
  46. ],
  47. // Yii2 user组件配置,可以参看:http://www.yiichina.com/doc/guide/2.0/input-validation#client-side-validation
  48. 'user' => [
  49. 'class' => 'fecshop\yii\web\User',
  50. 'identityClass' => 'fecshop\models\mysqldb\Customer',
  51. // 是否cookie 登录。
  52. /*
  53. * @var boolean whether to enable cookie-based login. Defaults to false.
  54. * Note that this property will be ignored if [[enableSession]] is false.
  55. * 设置为true的好处为,当浏览器关掉在打开,可以自动登录。
  56. */
  57. 'enableAutoLogin' => true,
  58. /*
  59. * authTimeout => 56666,
  60. * 这里请不要设置authTimeout,为了让customer账户session
  61. * 和cart的session保持一致,设置超时时间请统一在session组件
  62. * 中设置超时时间。
  63. */
  64. //'authTimeout' => 56666,
  65. ],
  66. // 404页面对应的链接。
  67. 'errorHandler' => [
  68. 'errorAction' => 'site/helper/error',
  69. ],
  70. // 首页对应的url
  71. 'urlManager' => [
  72. 'rules' => [
  73. '' => 'cms/home/index',
  74. ],
  75. ],
  76. /**
  77. * Yii2 Request组件,这里进行了重写,目的是为了实现URL自定义伪静态功能。
  78. * 关于fecshop的url伪静态部分,可以参看:http://www.fancyecommerce.com/2016/05/18/yii2-url-%E8%87%AA%E5%AE%9A%E4%B9%89-%E4%BC%AA%E9%9D%99%E6%80%81url/
  79. * 关于Yii2 request的一些知识,可以参看:http://www.yiichina.com/doc/guide/2.0/runtime-requests
  80. */
  81. 'request' => [
  82. 'class' => 'fecshop\yii\web\Request',
  83. /*
  84. 'enableCookieValidation' => true,
  85. 'enableCsrfValidation' => true,
  86. 'cookieValidationKey' => 'O1d232trde1x-M97_7QvwPo-5QGdkLMp#@#@',
  87. 'noCsrfRoutes' => [
  88. 'catalog/product/addreview',
  89. 'favorite/product/remark',
  90. 'paypal/ipn/index',
  91. 'paypal/ipn',
  92. ],
  93. */
  94. ],
  95. ],
  96. 'services' => [
  97. 'page' => [
  98. 'childService' => [
  99. 'theme' => [
  100. 'viewFileConfig' => [
  101. // 'catalog/category/index' => '@fecshop/app/appfront/theme/base/front/catalog/category/index.php',
  102. ],
  103. ],
  104. 'widget' => [
  105. 'widgetConfig' => [
  106. 'base' => [
  107. 'head' => [
  108. // 动态数据提供部分
  109. 'class' => 'fecshop\app\appfront\widgets\Head',
  110. // 根据多模板的优先级,依次去模板找查找该文件,直到找到这个文件。
  111. 'view' => 'widgets/head.php',
  112. // 缓存
  113. 'cache' => [
  114. 'timeout' => 4500, // 缓存过期时间
  115. ],
  116. ],
  117. 'header' => [
  118. 'class' => 'fecshop\app\appfront\widgets\Headers',
  119. // 根据多模板的优先级,依次去模板找查找该文件,直到找到这个文件。
  120. 'view' => 'widgets/header.php',
  121. 'cache' => [
  122. 'timeout' => 4500,
  123. ],
  124. ],
  125. 'topsearch' => [
  126. 'view' => 'widgets/topsearch.php',
  127. ],
  128. 'menu' => [
  129. 'class' => 'fecshop\app\appfront\widgets\Menu',
  130. // 根据多模板的优先级,依次去模板找查找该文件,直到找到这个文件。
  131. 'view' => 'widgets/menu.php',
  132. 'cache' => [
  133. //'timeout' => 4500,
  134. ],
  135. ],
  136. 'footer' => [
  137. 'class' => 'fecshop\app\appfront\widgets\Footer',
  138. // 根据多模板的优先级,依次去模板找查找该文件,直到找到这个文件。
  139. 'view' => 'widgets/footer.php',
  140. 'cache' => [
  141. //'timeout' => 4500,
  142. ],
  143. ],
  144. 'scroll' => [
  145. // 'class' => 'fecshop\app\appfront\modules\Cms\block\widgets\Scroll',
  146. // 根据多模板的优先级,依次去模板找查找该文件,直到找到这个文件。
  147. 'view' => 'widgets/scroll.php',
  148. ],
  149. 'breadcrumbs' => [
  150. 'view' => 'widgets/breadcrumbs.php',
  151. ],
  152. 'flashmessage' => [
  153. 'view' => 'widgets/flashmessage.php',
  154. ],
  155. 'trace' => [
  156. 'view' => 'widgets/trace.php',
  157. ],
  158. 'beforeContent' => [
  159. 'view' => 'widgets/beforeContent.php',
  160. ],
  161. ],
  162. 'home' => [
  163. 'product_price' => [
  164. 'class' => 'fecshop\app\appfront\modules\Catalog\block\category\Price',
  165. 'view' => 'cms/home/index/price.php',
  166. ],
  167. ],
  168. 'customer' => [
  169. 'left_menu' => [
  170. 'class' => 'fecshop\app\appfront\modules\Customer\block\LeftMenu',
  171. 'view' => 'customer/leftmenu.php'
  172. ],
  173. ],
  174. 'cms' => [
  175. 'productlist' => [
  176. 'view' => 'cms/home/index/product.php',
  177. ],
  178. 'indexproductlist' => [
  179. 'view' => 'cms/home/index/indexproduct.php',
  180. ],
  181. ],
  182. 'category' => [
  183. 'price' => [
  184. 'class' => 'fecshop\app\appfront\modules\Catalog\block\category\Price',
  185. 'view' => 'catalog/category/price.php',
  186. ],
  187. 'toolbar' => [
  188. 'view' => 'catalog/category/index/toolbar.php',
  189. ],
  190. 'filter_refineby' => [
  191. 'view' => 'catalog/category/index/filter/refineby.php',
  192. ],
  193. 'filter_subcategory' => [
  194. 'view' => 'catalog/category/index/filter/subcategory.php',
  195. ],
  196. 'filter_attr' => [
  197. 'view' => 'catalog/category/index/filter/attr.php',
  198. ],
  199. 'filter_price' => [
  200. 'view' => 'catalog/category/index/filter/price.php',
  201. ],
  202. ],
  203. 'product' => [
  204. 'price' => [
  205. 'view' => 'catalog/product/index/price.php'
  206. ],
  207. 'options' => [
  208. 'view' => 'catalog/product/index/options.php'
  209. ],
  210. 'tier_price' => [
  211. 'view' => 'catalog/product/index/tier_price.php'
  212. ],
  213. 'image' => [
  214. 'view' => 'catalog/product/index/image.php'
  215. ],
  216. 'buy_also_buy' => [
  217. 'view' => 'catalog/product/index/buy_also_buy.php'
  218. ],
  219. 'review' => [
  220. 'class' => 'fecshop\app\appfront\modules\Catalog\block\product\Review',
  221. 'view' => 'catalog/product/index/review.php',
  222. ],
  223. 'payment' => [
  224. 'view' => 'catalog/product/index/payment.php',
  225. ],
  226. ],
  227. 'search' => [
  228. 'toolbar' => [
  229. 'view' => 'catalogsearch/index/index/toolbar.php',
  230. ],
  231. ],
  232. // 下单页面
  233. 'order' => [
  234. 'shipping' => [
  235. 'view' => 'checkout/onepage/index/shipping.php'
  236. ],
  237. 'payment' => [
  238. 'view' => 'checkout/onepage/index/payment.php'
  239. ],
  240. 'view' => [
  241. 'view' => 'checkout/onepage/index/review_order.php'
  242. ],
  243. ],
  244. 'payment' => [
  245. 'paypal_express_address' => [
  246. 'view' => 'payment/paypal/express/review/address.php',
  247. ],
  248. 'paypal_express_shipping' => [
  249. 'view' => 'payment/paypal/express/review/shipping.php'
  250. ],
  251. 'paypal_express_orderview' => [
  252. 'view' => 'payment/paypal/express/review/review_order.php'
  253. ],
  254. ],
  255. ],
  256. ],
  257. ],
  258. ],
  259. ],
  260. ];
  261. // product 生产环境,errorHandler使用 AppfrontErrorHandler
  262. if (YII_ENV_PROD) {
  263. $config['components']['errorHandler']['class'] = 'fecshop\components\AppfrontErrorHandler';
  264. }
  265. return $config;