Pickles Framework Documentation

http.php

Table of Contents

Functions

json()  : Response
Returns a JSON response with the given data.
redirect()  : Response
Redirects the user to the specified URI.
view()  : Response
Renders a view and returns it as a HTTP response.
request()  : Request
Retrieves the current HTTP request instance.
back()  : Response
Redirects the user to the previous request URL stored in the session.

Functions

json()

Returns a JSON response with the given data.

json(array<string|int, mixed> $data) : Response
Parameters
$data : array<string|int, mixed>

The data to be encoded as JSON and returned in the response.

Return values
Response

The JSON response object.

redirect()

Redirects the user to the specified URI.

redirect(string $uri) : Response

This function generates a redirect response to the given URI.

Parameters
$uri : string

The URI to redirect to.

Return values
Response

The redirect response object.

view()

Renders a view and returns it as a HTTP response.

view(string $view[, array<string|int, mixed> $data = [] ][, string|null $layout = null ]) : Response
Parameters
$view : string

The name of the view file to render.

$data : array<string|int, mixed> = []

An associative array of data to pass to the view.

$layout : string|null = null

Optional layout to wrap the view content.

Return values
Response

The HTTP response containing the rendered view.

request()

Retrieves the current HTTP request instance.

request() : Request

This function fetches the current request object from the application kernel. If the application instance is not of type Kernel, an exception is thrown.

Tags
throws
Exception

If the application instance is not a Kernel.

Return values
Request

The current HTTP request instance.

back()

Redirects the user to the previous request URL stored in the session.

back() : Response

If no previous URL is found, it defaults to the root ("/").

Return values
Response

The HTTP response object for the redirection.


        
On this page

Search results