Please enable JavaScript.
Coggle requires JavaScript to display documents.
Symfony and HTTP Fundamentals (Requests and responses in PHP ($_SERVER, $…
Symfony and HTTP Fundamentals
Requests and responses in HTTP
Step 1: The Client sends a request
method (verb)
GET
POST
PUT/PATCH
DELETE
URI
Requests headers
Host
Accept
User-Agent
etc.
Step2: Server returns a response
Status code (200, 302, 404, etc.)
Headers
Content-Type (HTML, XML, JSON etc.)
and others headers...
Requests and responses in PHP
$_SERVER
$_GET
header()
Requests and Responses in Symfony
Symfony Request Object
$request->getPathInfo()
$request->query->get('id')
$request->request->get('category', 'default category')
$request->server->get('attachment')
$request->cookies->get('PHPSESSID')
$request->headers->get('hosts');
$request->headers->get('content_type')
$request->getMethod()
$request->getLanguages()
isSecure()
Symfony Response Object
$response->setContent('<html><body>test</body></html>')
$response->setStatusCode(Response::HTTP_OK)
$response->headers->set('Content-Type', 'text/html')
$response->send()
Sub-classes (JSON, redirect, stream ...)
font partie d'un composant autonome: symfony/http-foundation
permet aussi de gérer sessions
les téléchargements etc.
The journey form the request to response
The Front Controller