Example #1
0
<?php

include 'vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Simple Example
|--------------------------------------------------------------------------
|
| Basic example below creates a basic request object and using that information
| to display a simple message as a response.
|
*/
$request = \Sephedo\Http\Request::buildRequest();
$response = \Sephedo\Http\Response::buildResponse();
$response->getBody()->write("<h1>Simple Example</h1>\n");
$response->getBody()->write("<p>Thank you for visiting the <code>" . $request->getRequestTarget() . "</code> page.</p>\n");
$response->getBody()->write("<p>Please enjoy your stay.</p>\n");
echo $response->getBody();
/**
Result:
 
<h1>Hello Traveller</h1>
<p>Thank you for visiting the <code>/example.php</code> page.</p>
<p>Please enjoy your stay.</p>
*/
echo '<hr />';
/*
|--------------------------------------------------------------------------
| Advanced Example
|--------------------------------------------------------------------------
|
Example #2
0
 /**
  * Constructor
  *
  * @see Sephedo\Http\Request::__construct
  * @param array $cookies Array of key/value pairs representing cookies.
  * @param array $environment Array of values representing the server enviroment.
  * @param array An array tree of UploadedFileInterface instances.
  */
 public function __construct($method, Uri $uri, Headers $headers, $version, array $cookies, array $environment, StreamInterface $body, array $uploadedFiles)
 {
     parent::__construct($method, $uri, $headers, $version, $body);
     $this->environment = is_array($environment) ? $environment : [$environment];
     parse_str($this->uri->getQuery(), $queryParams);
     $this->withCookieParams($cookies)->withQueryParams($queryParams)->withUploadedFiles($uploadedFiles);
 }