Skip to content

Instantly share code, notes, and snippets.

@rodrigoSyscop
Last active February 17, 2018 19:42
Show Gist options
  • Select an option

  • Save rodrigoSyscop/8b41eb28a6add73b798ea02bcfb53aa3 to your computer and use it in GitHub Desktop.

Select an option

Save rodrigoSyscop/8b41eb28a6add73b798ea02bcfb53aa3 to your computer and use it in GitHub Desktop.
Http Foundation Request API
<?php
// a URI requisitada (ex: /about) menos a query string
$request->getPathInfo();
// recebe variáveis GET['foo'] e POST['bar'] respectivamente
$request->query->get('foo');
$request->request->get('bar', 'valor padrão, caso "bar" no exista');
// recebe variáveis do array $_SERVER
$request->server->get('HTTP_HOST');
// recebe uma instância de UploadedFile identificado por foo
$request->files->get('foo');
// recebe o valor de um COOKIE
$request->cookies->get('PHPSESSID');
// recebe um cabeçalho HTTP, com as chaves normalizadas em minúsculas
$request->headers->get('host');
$request->headers->get('content_type');
$request->getMethod(); // GET, POST, PUT, DELETE, HEAD
$request->getLanguages(); // um array com as linguagens aceitas pelo cliente
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment