inMagentoMagento2Tutorial,AreasinMagento这篇Magento2教程主要给大家讲解一下MagentoArea的原理是什么,在Magento中用到什么地方。方便大家在具体工作中使用时不怕,甚至可以游刃有余。More《Magento 2 教程》Areasarea在Magento中是一个逻辑组件,用于组织请求处理相关的代码。对于area,很多时候我们不需要做特殊的处理,但是了解area对于理解Magento来说是非常重要的。Magento\Framework\App\Area类中的AREA_*相关常量表示区域的类型。大致有以下几种:constAREA_GLOBAL='global';constAREA_FRONTEND='前端';constAREA_ADMINHTML='adminhtml';constAREA_DOC='doc';constAREA_CRONTAB='crontab';constAREA_WEBAPI_REST='webapi_rest';='webapi_soap';通过搜索di.xml文件中的/module-backend/etc/di.xml位于/module-webapi/etc/di.xmlwebapi_rest位于/magento/module-webapi/etc/di.xmlwebapi_soap位于/magento/module-store/etc/di.xml的前端位于/magento/module-cron/etc/di.xml。crontab的默认区域是frontend,由module-store/etc/di.xml文件中的默认参数定义。globalarea是没有adminhtml和frontendarea的默认区域。查看/module-webapi/etc/di.xml文件中的示例。<项目名称="frontName"xsi:type="string">restsoapfrontName有时会出现在URL中,name用来指代内部配置文件中对应的区域,Magento中定义不同的区域,其中包含处理URL和请求的各种相关代码。优点是Magento只需要加载相应区域下的特定代码即可。更多信息参见:https://www.kancloud.cn/yuesi...