Application
class Application extends Container implements HttpKernelInterface, TerminableInterface
The Silex framework class.
Constants
VERSION |
|
EARLY_EVENT |
|
LATE_EVENT |
|
Properties
protected | $providers | ||
protected | $booted |
Methods
Instantiate a new Application.
Registers a service provider.
Boots all service providers.
Maps a pattern to a callable.
Maps a GET request to a callable.
Maps a POST request to a callable.
Maps a PUT request to a callable.
Maps a DELETE request to a callable.
Maps an OPTIONS request to a callable.
Maps a PATCH request to a callable.
Adds an event listener that listens on the specified events.
Registers a before filter.
Registers an after filter.
Registers a finish filter.
Aborts the current request by sending a proper HTTP error.
Registers an error handler.
Registers a view handler.
Flushes the controller collection.
Redirects the user to another URL.
Creates a streaming response.
Escapes a text for HTML.
Convert some data into a JSON response.
Sends a file.
Mounts controllers under the given route prefix.
Handles the request and delivers the response.
{@inheritdoc}
{@inheritdoc}
Details
at line 59
__construct(array $values = array())
Instantiate a new Application.
Objects and parameters can be passed as argument to the constructor.
at line 86
Application
register(ServiceProviderInterface $provider, array $values = array())
Registers a service provider.
at line 101
boot()
Boots all service providers.
This method is automatically called by handle(), but you can use it to boot all service providers when not handling a request.
at line 130
Controller
match(string $pattern, mixed $to = null)
Maps a pattern to a callable.
You can optionally specify HTTP methods that should be matched.
at line 143
Controller
get(string $pattern, mixed $to = null)
Maps a GET request to a callable.
at line 156
Controller
post(string $pattern, mixed $to = null)
Maps a POST request to a callable.
at line 169
Controller
put(string $pattern, mixed $to = null)
Maps a PUT request to a callable.
at line 182
Controller
delete(string $pattern, mixed $to = null)
Maps a DELETE request to a callable.
at line 195
Controller
options(string $pattern, mixed $to = null)
Maps an OPTIONS request to a callable.
at line 208
Controller
patch(string $pattern, mixed $to = null)
Maps a PATCH request to a callable.
at line 221
on(string $eventName, callable $callback, int $priority)
Adds an event listener that listens on the specified events.
at line 245
before(mixed $callback, int $priority)
Registers a before filter.
Before filters are run before any route has been matched.
at line 271
after(mixed $callback, int $priority)
Registers an after filter.
After filters are run after the controller has been executed.
at line 298
finish(mixed $callback, int $priority)
Registers a finish filter.
Finish filters are run after the response has been sent.
at line 314
abort(int $statusCode, string $message = '', array $headers = array())
Aborts the current request by sending a proper HTTP error.
at line 336
error(mixed $callback, int $priority = -8)
Registers an error handler.
Error handlers are simple callables which take a single Exception as an argument. If a controller throws an exception, an error handler can return a specific response.
When an exception occurs, all handlers will be called, until one returns something (a string or a Response object), at which point that will be returned to the client.
For this reason you should add logging handlers before output handlers.
at line 353
view(mixed $callback, int $priority)
Registers a view handler.
View handlers are simple callables which take a controller result and the request as arguments, whenever a controller returns a value that is not an instance of Response. When this occurs, all suitable handlers will be called, until one returns a Response object.
at line 361
flush()
Flushes the controller collection.
at line 374
RedirectResponse
redirect(string $url, int $status = 302)
Redirects the user to another URL.
at line 388
StreamedResponse
stream(mixed $callback = null, int $status = 200, array $headers = array())
Creates a streaming response.
at line 403
string
escape(string $text, int $flags = ENT_COMPAT, string $charset = null, bool $doubleEncode = true)
Escapes a text for HTML.
at line 417
JsonResponse
json(mixed $data = array(), int $status = 200, array $headers = array())
Convert some data into a JSON response.
at line 432
BinaryFileResponse
sendFile(SplFileInfo|string $file, int $status = 200, array $headers = array(), null|string $contentDisposition = null)
Sends a file.
at line 447
Application
mount(string $prefix, ControllerCollection|callable|ControllerProviderInterface $controllers)
Mounts controllers under the given route prefix.
at line 471
run(Request $request = null)
Handles the request and delivers the response.
at line 488
handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{@inheritdoc}
If you call this method directly instead of run(), you must call the terminate() method yourself if you want the finish filters to be run.
at line 502
terminate(Request $request, Response $response)
{@inheritdoc}