PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Subclassing the Request Object

The base request class used for all request objects is the abstract class Zend_Controller_Request_Abstract. At its most basic, it defines the following methods:

<?php
abstract class Zend_Controller_Request_Abstract
{
    
/**
     * @return string
     */
    
public function getControllerName();

    
/**
     * @param string $value
     * @return self
     */
    
public function setControllerName($value);

    
/**
     * @return string
     */
    
public function getActionName();

    
/**
     * @param string $value
     * @return self
     */
    
public function setActionName($value);

    
/**
     * @return string
     */
    
public function getControllerKey();

    
/**
     * @param string $key
     * @return self
     */
    
public function setControllerKey($key);

    
/**
     * @return string
     */
    
public function getActionKey();

    
/**
     * @param string $key
     * @return self
     */
    
public function setActionKey($key);

    
/**
     * @param string $key
     * @return mixed
     */
    
public function getParam($key);

    
/**
     * @param string $key
     * @param mixed $value
     * @return self
     */
    
public function setParam($key$value);

    
/**
     * @return array
     */
     
public function getParams();

    
/**
     * @param array $array
     * @return self
     */
    
public function setParams(array $array);

    
/**
     * @param boolean $flag
     * @return self
     */
    
public function setDispatched($flag true);

    
/**
     * @return boolean
     */
    
public function isDispatched();
}

The request object is a container for the request environment. The controller chain really only needs to know how to set and retrieve the controller, action, optional parameters, and dispatched status. By default, the request will search its own parameters using the controller or action keys in order to determine the controller and action.

Extend this class, or one of its derivatives, when you need the request class to interact with a specific environment in order to retrieve data for use in the above tasks. Examples include the HTTP environment, a CLI environment, or a PHP-GTK environment.

Zend Framework