Accessing The Request

A instance of the current HTTP request as a \wiggum\http\Request object is always passed into your Controller. The current request instance will automatically be populated for you:

<?php
namespace app\components\helloWorld;

use \wiggum\model\Component;
use \wiggum\model\Request;
use \wiggum\model\Response;

class HelloWorld extends Controller 
{
	
	// ...
	
	/**
     *
     * @param  Request  $request
     * @param  Response  $response
     * @return Response
     */
	public function doDefault(Request $request, Response $response) 
	{
		$name = $request->getParameter('name');
		
		return $response;
	}
	
	// ...
}

Route parameters are also stored in the Request object and can be retreived with $request->getParameter('name');.

Methods

Method Parameters Description
getRequestURI - Returns the URI which was given in order to access this page; for instance, '/blog/'. This also includes the query string if one exists.
getParameter $name
$default = null
Returns the value of a request parameter as a String, or null if the parameter does not exist. Setting a default will let you fallback back if the parameter is not found. Request parameters are extra information sent with the request. For HTTP requests, parameters are contained in the query string or posted form data.
getParameter $name
$default = null
Returns the value of a request parameter as a String, or null if the parameter does not exist. Setting a default will let you fallback back if the parameter is not found. Request parameters are extra information sent with the request. For HTTP requests, parameters are contained in the query string or posted form data.
getServerName - Returns the name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
getContextPath - Returns the portion of the request URI that indicates the context of the request.
getContextPathSegments - Returns an array of each segement of the context path, broken up by the character '/'.
getContextPathSegment index Returns a specfic segement of the of context path..
getParameters index Returns an associative array that by default contains the contents of $_GET, $_POST and $_COOKIE. If the request has no parameters, the method returns an empty array.
hasParameter $name Returns a boolean if a parameter exists.
getAttribute $name
$default = null
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists. Setting a default will let you fallback back if the attribute is not found.
setAttribute $name
value
Stores an attribute in this request. Attributes are reset between requests.
hasAttribute $name
Returns a boolean if a attribute exists.
getFiles - Returns an associative array that by default contains the contents of $_FILE that have been reorganized.
getFile $name
Returns a associative array of File object for the specified file saved on the server's filesystem, or null if the file was not included in the upload.