App

App This is the primary class with which you instantiate, configure, and run a Slim Framework application. The \Slim\App class also accepts Slim Framework middleware.
uses Slim\MiddlewareAwareTrait

Known subclasses

Wtf\App
Methods Summary
public
# __construct( \ContainerInterface|array $container = array ( ) )
Create new application
public
# getContainer( )
Enable access to the DI container by consumers of $app
public
# add( callable|string $callable )
Add middleware This method prepends new middleware to the app's middleware stack.
public
# __call( string $method , array $args )
Calling a non-existant method on App checks to see if there's an item in the container that is callable and if so, calls it.
public
# get( string $pattern , callable|string $callable )
Add GET route
public
# post( string $pattern , callable|string $callable )
Add POST route
public
# put( string $pattern , callable|string $callable )
Add PUT route
public
# patch( string $pattern , callable|string $callable )
Add PATCH route
public
# delete( string $pattern , callable|string $callable )
Add DELETE route
public
# options( string $pattern , callable|string $callable )
Add OPTIONS route
public
# any( string $pattern , callable|string $callable )
Add route for any HTTP method
public
# map( array $methods , string $pattern , callable|string $callable )
Add route with multiple methods
public
# group( string $pattern , callable $callable )
Route Groups This method accepts a route pattern and a callback. All route declarations in the callback will be prepended by the group(s) that it is in.
public
# run( bool|bool $silent = false )
Run application This method traverses the application middleware stack and then sends the resultant Response object to the HTTP client.
protected
# processInvalidMethod( Psr\Http\Message\ServerRequestInterface $request , Psr\Http\Message\ResponseInterface $response )
Pull route info for a request with a bad method to decide whether to return a not-found error (default) or a bad-method error, then run the handler for that error, returning the resulting response. Used for cases where an incoming request has an unrecognized method, rather than throwing an exception and not catching it all the way up.
public
# process( Psr\Http\Message\ServerRequestInterface $request , Psr\Http\Message\ResponseInterface $response )
Process a request This method traverses the application middleware stack and then returns the resultant Response object.
public
# respond( Psr\Http\Message\ResponseInterface $response )
Send the response to the client
public
# __invoke( Psr\Http\Message\ServerRequestInterface $request , Psr\Http\Message\ResponseInterface $response )
Invoke application This method implements the middleware interface. It receives Request and Response objects, and it returns a Response object after compiling the routes registered in the Router and dispatching the Request object to the appropriate Route callback routine.
public
# subRequest( string $method , string $path , string $query = '', array $headers = array ( ), array $cookies = array ( ), string $bodyContent = '', Psr\Http\Message\ResponseInterface $response = NULL )
Perform a sub-request from within an application route This method allows you to prepare and initiate a sub-request, run within the context of the current request. This WILL NOT issue a remote HTTP request. Instead, it will route the provided URL, method, headers, cookies, body, and server variables against the set of registered application routes. The result response object is returned.
protected
# dispatchRouterAndPrepareRoute( Psr\Http\Message\ServerRequestInterface $request , Slim\Interfaces\RouterInterface $router )
Dispatch the router to find the route. Prepare the route for use.
protected
# finalize( Psr\Http\Message\ResponseInterface $response )
Finalize response
protected
# isEmptyResponse( Psr\Http\Message\ResponseInterface $response )
Helper method, which returns true if the provided response must not output a body and false if the response could have a body.

see

protected
# handleException( Exception $e , Psr\Http\Message\ServerRequestInterface $request , Psr\Http\Message\ResponseInterface $response )
Call relevant handler from the Container if needed. If it doesn't exist, then just re-throw.
protected
# handlePhpError( Throwable $e , Psr\Http\Message\ServerRequestInterface $request , Psr\Http\Message\ResponseInterface $response )
Call relevant handler from the Container if needed. If it doesn't exist, then just re-throw.
Methods used from Slim\MiddlewareAwareTrait trait
addMiddleware() seedMiddlewareStack() callMiddlewareStack()
Constants Summary
public string VERSION
Current version
# '3.9.2'
Properties used from Slim\MiddlewareAwareTrait
$tip , $middlewareLock