Zend_Controller jest sercem systemu MVC
biblioteki Zend Framework. MVC oznacza Zend_Controller_Front implementuje wzorzec projektowy
Zend_Controller system was built with extensibility
in mind, either by subclassing the existing classes, writing new
classes that implement the various interfaces and abstract classes
that form the foundation of the controller family of classes, or
writing plugins or action helpers to augment or manipulate the
functionality of the system.
html znajdujący się w powyższej przykładowej
strukturze katalogów.
html/.htaccess aby wyglądał w taki
sposób:
html/index.php.
Otwórz plik html/index.php w dowolnym edytorze i
dodaj poniższy kod:
http://framework.zend.com/roadmap/components, the
path is /roadmap/components, which will map to the
controller roadmap and the action
components. If no action is provided, the action
index is assumed, and if no controller is provided,
the controller index is assumed (following the
Apache convention that maps a DirectoryIndex
automatically).
Zend_Controller's dispatcher then takes the
controller value and maps it to a class. By default, it
Title-cases the controller name and appends the word
Controller. Thus, in our example above, the
controller roadmap is mapped to the class
RoadmapController.
Action is appended. Thus, in our example
above, the action components becomes
componentsAction, and the final method called is
RoadmapController::componentsAction().
index. Otwórz w edytorze plik
application/controllers/IndexController.php, i
dodaj poniższy kod:
Zend_View is used as the View layer in the MVC. The
ViewRenderer does some magic, and uses the
controller name (e.g., index) and the current
action name (e.g., index) to determine what
template to pull. By default, templates end in the
.phtml extension, so this means that, in the above
example, the template index/index.phtml will be
rendered. Additionally, the ViewRenderer
automatically assumes that the directory views at
the same level as the controller directory will be the base view
directory, and that the actual view scripts will be in the
views/scripts/ subdirectory. Thus, the template
rendered will be found in
application/views/scripts/index/index.phtml.
application/views/scripts/; the view script for the
default controller and action is in
application/views/scripts/index/index.phtml. Create
this file, and type in some HTML:
ErrorController in the
default module with an errorAction method:
application/controllers/ErrorController.php.
You will also need to create a view script in
application/views/scripts/error/error.phtml; sample
content might look like:
Wystąpił błąd; spróbuj ponownie później.
]]>example.com is your domain, any of the following
URLs will get to the page we've just created:
http://example.com/http://example.com/indexhttp://example.com/index/index