Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP Dev Heisenberg Level

PHP Dev Heisenberg Level

My talk for Barcampnea 2016
Thanks!

Diego Maximiliano

May 28, 2016
Tweet

More Decks by Diego Maximiliano

Other Decks in Programming

Transcript

  1. Request & Response POST /task?id=1 HTTP/1.1 Host: example.org User-Agent: Mozilla/5.0

    (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 Accept-Language: en-US,en;q=0.8 Content-Type: application/json; charset=utf-8 Content-Length: 137 { "status": "ok", "extended": true, "results": [ {"value": 0, "type": "int64"}, {"value": 1.0e+3, "type": "decimal"} ] } HTTP/1.1 200 OK Date: Sat, 02 Apr 2011 21:05:05 GMT Server: lighttpd/1.4.19 Content-Type: text/html <html> <!-- ... HTML for the xkcd comic --> </html>
  2. Request & Response POST /task?id=1 HTTP/1.1 Host: example.org User-Agent: Mozilla/5.0

    (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 Accept-Language: en-US,en;q=0.8 Content-Type: application/json; charset=utf-8 Content-Length: 137 { "status": "ok", "extended": true, "results": [ {"value": 0, "type": "int64"}, {"value": 1.0e+3, "type": "decimal"} ] } HTTP/1.1 200 OK Date: Sat, 02 Apr 2011 21:05:05 GMT Server: lighttpd/1.4.19 Content-Type: text/html <html> <!-- ... HTML for the xkcd comic --> </html>
  3. Request POST /task?id=1 HTTP/1.1 Host: example.org User-Agent: Mozilla/5.0 (X11; Linux

    x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 Accept-Language: en-US,en;q=0.8 Content-Type: application/json; charset=utf-8 Content-Length: 137
  4. Request POST /task?id=1 HTTP/1.1 Host: example.org User-Agent: Mozilla/5.0 (X11; Linux

    x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 Accept-Language: en-US,en;q=0.8 Content-Type: application/json; charset=utf-8 Content-Length: 137 User-Agent
  5. Request POST /task?id=1 HTTP/1.1 Host: example.org User-Agent: Mozilla/5.0 (X11; Linux

    x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 Accept-Language: en-US,en;q=0.8 Content-Type: application/json; charset=utf-8 Content-Length: 137 Accept-Language
  6. Response HTTP/1.1 200 OK Date: Sat, 02 Apr 2011 21:05:05

    GMT Server: lighttpd/1.4.19 Content-Type: text/html <html> <!-- ... HTML for the xkcd comic --> </html> 200 OK
  7. Response HTTP/1.1 200 OK Date: Sat, 02 Apr 2011 21:05:05

    GMT Server: lighttpd/1.4.19 Content-Type: text/html <html> <!-- ... HTML for the xkcd comic --> </html> https://httpstatuses.com/
  8. $client = new GuzzleHttp\Client(); $res = $client->request('GET', 'https://api.github.com/user', [ 'auth'

    => ['user', 'pass'] ]); echo $res->getStatusCode(); // "200" echo $res->getHeader('content-type'); // 'application/json; charset=utf8' echo $res->getBody();
  9. use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface;

    use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Csrf\CsrfToken; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Form; use Symfony\Component\Form\FormBuilder; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Doctrine\Bundle\DoctrineBundle\Registry; use Symfony\Component\HttpFoundation\{Response, RedirectResponse, StreamedResponse};
  10. Cookies? $cookie_name = "user"; $cookie_value = "John Doe"; setcookie($cookie_name, $cookie_value,time()

    + (86400 * 30), "/"); if(!isset($_COOKIE[$cookie_name])) { echo "Cookie named '" . $cookie_name . "' is not set!"; } else { echo "Cookie '" . $cookie_name . "' is set!<br>"; echo "Value is: " . $_COOKIE[$cookie_name]; }