public
|
#
__construct( Psr\Container\ContainerInterface|array $container = [] )
Create new application
Parameters
- $container
- Either a ContainerInterface or an associative array of app settings
Throws
InvalidArgumentException when no container is provided that implements ContainerInterface
|
public
Psr\Container\ContainerInterface
|
#
getContainer( )
Enable access to the DI container by consumers of $app
Enable access to the DI container by consumers of $app
Returns
Psr\Container\ContainerInterface
|
public
static
|
#
add( callable|string $callable )
Add middleware
This method prepends new middleware to the app's middleware stack.
Parameters
- $callable
- The callback routine
Returns
static
|
public
mixed
|
#
__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.
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.
Parameters
Returns
mixed
|
public
Slim\Interfaces\RouteInterface
|
#
get( string $pattern, callable|string $callable )
Add GET route
Parameters
- $pattern
- The route URI pattern
- $callable
- The route callback routine
Returns
|
public
Slim\Interfaces\RouteInterface
|
#
post( string $pattern, callable|string $callable )
Add POST route
Parameters
- $pattern
- The route URI pattern
- $callable
- The route callback routine
Returns
|
public
Slim\Interfaces\RouteInterface
|
#
put( string $pattern, callable|string $callable )
Add PUT route
Parameters
- $pattern
- The route URI pattern
- $callable
- The route callback routine
Returns
|
public
Slim\Interfaces\RouteInterface
|
#
patch( string $pattern, callable|string $callable )
Add PATCH route
Parameters
- $pattern
- The route URI pattern
- $callable
- The route callback routine
Returns
|
public
Slim\Interfaces\RouteInterface
|
#
delete( string $pattern, callable|string $callable )
Add DELETE route
Parameters
- $pattern
- The route URI pattern
- $callable
- The route callback routine
Returns
|
public
Slim\Interfaces\RouteInterface
|
#
options( string $pattern, callable|string $callable )
Add OPTIONS route
Parameters
- $pattern
- The route URI pattern
- $callable
- The route callback routine
Returns
|
public
Slim\Interfaces\RouteInterface
|
#
any( string $pattern, callable|string $callable )
Add route for any HTTP method
Add route for any HTTP method
Parameters
- $pattern
- The route URI pattern
- $callable
- The route callback routine
Returns
|
public
Slim\Interfaces\RouteInterface
|
#
map( array $methods, string $pattern, callable|string $callable )
Add route with multiple methods
Add route with multiple methods
Parameters
- $methods
- Numeric array of HTTP method names
- $pattern
- The route URI pattern
- $callable
- The route callback routine
Returns
|
public
Slim\Interfaces\RouteGroupInterface
|
#
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.
Parameters
Returns
|
public
Psr\Http\Message\ResponseInterface
|
#
run( boolean|false $silent = false )
Run application
This method traverses the application middleware stack and then sends the
resultant Response object to the HTTP client.
Parameters
Returns
Psr\Http\Message\ResponseInterface
Throws
|
protected
Psr\Http\Message\ResponseInterface
|
#
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.
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.
Parameters
Returns
Psr\Http\Message\ResponseInterface
|
public
Psr\Http\Message\ResponseInterface
|
#
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.
Parameters
Returns
Psr\Http\Message\ResponseInterface
Throws
|
public
|
#
respond( Psr\Http\Message\ResponseInterface $response )
Send the response the client
Send the response the client
Parameters
|
public
Psr\Http\Message\ResponseInterface
|
#
__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.
Parameters
- $request
- The most recent Request object
- $response
- The most recent Response object
Returns
Psr\Http\Message\ResponseInterface
Throws
|
public
Psr\Http\Message\ResponseInterface
|
#
subRequest( string $method, string $path, string $query = '', array $headers = [], array $cookies = [], string $bodyContent = '', Psr\Http\Message\ResponseInterface $response = null )
Perform a sub-request from within an application route
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.
Parameters
- $method
- The request method (e.g., GET, POST, PUT, etc.)
- $path
- The request URI path
- $query
- The request URI query string
- $headers
- The request headers (key-value array)
- $cookies
- The request cookies (key-value array)
- $bodyContent
- The request body
- $response
- The response object (optional)
Returns
Psr\Http\Message\ResponseInterface
|
protected
Psr\Http\Message\ServerRequestInterface
|
#
dispatchRouterAndPrepareRoute( Psr\Http\Message\ServerRequestInterface $request, Slim\Interfaces\RouterInterface $router )
Dispatch the router to find the route. Prepare the route for use.
Dispatch the router to find the route. Prepare the route for use.
Parameters
Returns
Psr\Http\Message\ServerRequestInterface
|
protected
Psr\Http\Message\ResponseInterface
|
#
finalize( Psr\Http\Message\ResponseInterface $response )
Finalize response
Parameters
Returns
Psr\Http\Message\ResponseInterface
|
protected
boolean
|
#
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.
Helper method, which returns true if the provided response must not output a body and false
if the response could have a body.
Parameters
Returns
boolean
See
https://tools.ietf.org/html/rfc7231
|
protected
Psr\Http\Message\ResponseInterface
|
#
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.
Call relevant handler from the Container if needed. If it doesn't exist,
then just re-throw.
Parameters
Returns
Psr\Http\Message\ResponseInterface
Throws
Exception if a handler is needed and not found
|
protected
Psr\Http\Message\ResponseInterface
|
#
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.
Call relevant handler from the Container if needed. If it doesn't exist,
then just re-throw.
Parameters
Returns
Psr\Http\Message\ResponseInterface
Throws
Throwable
|