magento执行流程
2017-03-07 14:57
134 查看
转载:http://www.imooc.com/article/4889#0-qzone-1-15797-d020d2d2a4e8d1a374a433f596ad1440
电商网站框架Magento的执行流程,一张图就可完全说明。
magento也是mvc模式的程序,但是与普通的mvc结构又有所差异。
我们通过它的一个注册来看他的程序执行流程:
首先,我们在地址栏输入http://localhost/magento/index.php/customer/account/create/来进入注册的页面。
step 1:程序拿到url中的customer会自动定位到模块 app/code/core/Mage/Customer
step 2:然后程序得到account会自动定位到控制器文件 app/code/core/Mage/Customer/controllers/AccountController.php
step 3:程序得到create,则会在刚刚找到的控制器文件中createAction()方法。
step 4:执行程序装载目录 app/design/frontend/base/default/layout/下的customer.xml。然后寻找名为的标签
step 5:在customer.xml中定义了要使用的block和template,相对应的文件目录分别为:app\code\core\Mage\Customer\Block\Form\Register.php 和app\design\frontend\base\default\template\customer\form\register.phtml
在template文件中可以使用$this来访问类的方法。
所以,magento的程序执行流程可以归纳为这样:
获得执行控制器->执行方法中处理业务逻辑和模型数据->控制器实例化布局对象->布局对象根据请求实例化block->block与template一一对应完成显示逻辑
电商网站框架Magento的执行流程,一张图就可完全说明。
magento也是mvc模式的程序,但是与普通的mvc结构又有所差异。
我们通过它的一个注册来看他的程序执行流程:
首先,我们在地址栏输入http://localhost/magento/index.php/customer/account/create/来进入注册的页面。
step 1:程序拿到url中的customer会自动定位到模块 app/code/core/Mage/Customer
step 2:然后程序得到account会自动定位到控制器文件 app/code/core/Mage/Customer/controllers/AccountController.php
step 3:程序得到create,则会在刚刚找到的控制器文件中createAction()方法。
public function createAction(){ $this->_redirect('*/*'); return; } $this->loadLayout(); $this->_initLayoutMessages('customer/session'); $this->renderLayout(); }
step 4:执行程序装载目录 app/design/frontend/base/default/layout/下的customer.xml。然后寻找名为的标签
<customer_account_create translate="label"> <label>Customer Account Registration Form</label> <!-- Mage_Customer --> <remove name="right"/> <reference name="root"> <action method="setTemplate"> <template>page/1column.phtml</template> </action> </reference> <reference name="content"> <block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label"> <label>Form Fields Before</label> </block> </block> </customer_account_create>
step 5:在customer.xml中定义了要使用的block和template,相对应的文件目录分别为:app\code\core\Mage\Customer\Block\Form\Register.php 和app\design\frontend\base\default\template\customer\form\register.phtml
在template文件中可以使用$this来访问类的方法。
所以,magento的程序执行流程可以归纳为这样:
获得执行控制器->执行方法中处理业务逻辑和模型数据->控制器实例化布局对象->布局对象根据请求实例化block->block与template一一对应完成显示逻辑
相关文章推荐
- 详解Magento执行流程
- magento 程序执行流程和架构
- 构造函数的理解和程序执行流程
- [置顶] 【MySql】Sql优化(一)——Sql执行流程
- Lighttpd(linux lighttpd)中CGI执行流程
- struts2的执行流程(执行原理)
- springmvc的执行流程
- nginx-configure执行大致流程
- linux make menuconfig 执行流程小结
- Unity脚本生命周期, Unity脚本函数执行流程与顺序
- 2018-1-31第四章控制执行流程
- Hadoop MapReduce 任务执行流程源代码详细解析
- Java:程序执行流程+命令行获取命令
- 深入跟踪MFC程序的执行流程
- 阐述struts2的执行流程。
- Java中,if-else if- else语句执行流程
- android-Activity的执行流程
- 51单片机程序执行流程(STARTUP.A51) [李园7舍_404]
- 2. sed执行的流程
- Lighttpd中CGI执行流程