LaravelRequest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php namespace Symfony\Component\HttpFoundation;
  2. class LaravelRequest extends Request {
  3. /**
  4. * Creates a new request with values from PHP's super globals.
  5. *
  6. * @return Request A new request
  7. *
  8. * @api
  9. */
  10. static public function createFromGlobals()
  11. {
  12. $request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
  13. if (0 === strpos($request->server->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
  14. && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
  15. ) {
  16. parse_str($request->getContent(), $data);
  17. if (magic_quotes()) $data = array_strip_slashes($data);
  18. $request->request = new ParameterBag($data);
  19. }
  20. return $request;
  21. }
  22. /**
  23. * Get the root URL of the application.
  24. *
  25. * @return string
  26. */
  27. public function getRootUrl()
  28. {
  29. return $this->getScheme().'://'.$this->getHttpHost().$this->getBasePath();
  30. }
  31. }