Zend 프레임워크 튜토리얼: MVC 프레임워크의 컨트롤러 사용량 분석
이 문서에서는 Zend Framework 튜토리얼의 MVC 프레임워크에서 Controller를 사용하는 방법을 설명합니다. 참고하실 수 있도록 모두와 공유해 주세요. 자세한 내용은 다음과 같습니다.
다음은 MVC 모델에서 Controller의 기본 사용에 대해 간략하게 소개합니다.
기본 사용 예:
root@coder-671T-M:/www/zf_demo1/application# tree.
├── Bootstrap.php
├── configs
│ └── application.ini
├── 컨트롤러
│ ├── ErrorController.php
│ └── IndexController.php
├── 모델
└── 보기
├── 도우미
└── 스크립트
├── 오류
│ └── error.phtml
└── index
└── index.phtml
IndexController.php
<?php class IndexController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { // action body } }
규칙:
1. 일반적으로 컨트롤러는 /application/controllers 디렉터리에 저장됩니다. 응용 프로그램.
다음 방법으로 경로를 사용자 정의할 수 있습니다.
Zend_Controller_Front::run('/path/to/app/controllers');
또는 다음 방법으로 경로를 사용자 정의할 수 있습니다.
// Set the default controller directory: $front->setControllerDirectory('../application/controllers'); // Set several module directories at once: $front->setControllerDirectory(array( 'default' => '../application/controllers', 'blog' => '../modules/blog/controllers', 'news' => '../modules/news/controllers', )); // Add a 'foo' module directory: $front->addControllerDirectory('../modules/foo/controllers', 'foo');
기본적으로 기본 디렉터리에 저장할 수 있습니다.
2. 파일명과 클래스명이 동일합니다
3. 클래스명은 Controller로 끝나며 Zend_Controller_Action을 상속받습니다
4. 클래스명의 첫 글자는 대문자로 표기하며 카멜 표기법을 따릅니다. 스타일. Profit NewsListControlle
4. 파일 이름은 Controller.php로 끝납니다
5. 컨트롤러 초기화는 init 메소드
public function init() { }
에서 완료할 수 있습니다.
이 글이 PHP 프로그래밍에 종사하는 모든 분들께 도움이 되기를 바랍니다. Zend Framework 튜토리얼과 MVC 프레임워크 컨트롤러 사용 분석 관련 기사를 더 보려면 PHP 중국어 웹사이트를 주목하세요!
핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제









