Magento의 실행 과정은 한 장의 사진으로 다 설명할 수 있습니다.
Magento도 MVC 모드 프로그램이지만 일반적인 MVC 구조와는 다릅니다.
등록 중 하나를 통해 프로그램 실행 과정을 살펴보겠습니다.
먼저 주소 표시줄에 http://localhost/magento/index.php/customer/account/create/를 입력하여 등록 페이지로 들어갑니다. .
1단계: 프로그램이 URL에서 고객을 가져오면 자동으로 모듈 app/code/core/Mage/Customer를 찾습니다.
2단계: 그런 다음 프로그램이 계정을 가져오면 자동으로 모듈을 찾습니다. 컨트롤러 파일 app/code/core/ Mage/Customer/controllers/AccountController.php
3단계: 프로그램이 생성되면 방금 찾은 컨트롤러 파일에 createAction() 메서드가 생성됩니다.
<code>public function createAction(){ if ($this->_getSession()->isLoggedIn()) { $this->_redirect('*/*'); return; } $this->loadLayout(); $this->_initLayoutMessages('customer/session'); $this->renderLayout(); }</code>
4단계: 프로그램 로딩 디렉터리 app/design/frontend/base/default/layout/에서 customer.xml을 실행합니다. 그런 다음
<code><customer_account_create translate="label"> <label>Customer Account Registration Form</label> <!-- Mage_Customer --> <remove name="right"/> <remove name="left"/> <reference name="root"> <action method="setTemplate"><template>page/1column.phtml</template></action> </reference> <reference name="content"> <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml"> <block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label"> <label>Form Fields Before</label> </block> </block> </reference> </customer_account_create></code>
5단계: customer.xml에서 사용할 블록과 템플릿을 정의합니다. 해당 파일 디렉터리는 appcodecoreMageCustomerBlockFormRegister.php 및 appdesignfrontendbasedefaultcustomerformregister입니다. >템플릿 파일에서 $this를 사용하여 클래스 메서드에 액세스할 수 있습니다.
그래서 Magento의 프로그램 실행 프로세스는 다음과 같이 요약할 수 있습니다.
실행 컨트롤러 획득 -> 실행 메서드에서 비즈니스 로직 및 모델 데이터 처리 -> 컨트롤러가 레이아웃 객체를 인스턴스화합니다. 요청 인스턴스화 블록->블록 및 템플릿을 일대일 대응으로 기반으로 디스플레이 로직을 완성합니다.