PHP code example of davidecesarano / embryo-http

1. Go to this page and download the library: Download davidecesarano/embryo-http library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

davidecesarano / embryo-http example snippets


$request = (new RequestFactory)->createRequest('GET', 'http://example.com');

$response = (new ResponseFactory)->createResponse(200);

// create a new server-side request
$request = (new ServerRequestFactory)->createServerRequest('GET', 'http://example.com');

// create a new server-side request from server
$request = (new ServerRequestFactory)->createServerRequestFromServer();

// create a new stream from a string
$stream = (new StreamFactory)->createStream('Hello World!');

// create a stream from an existing file
$stream = (new StreamFactory)->createStreamFromFile('/path/file');

// create a new stream from an existing resource
$resource = fopen('php://temp', 'w+');
$stream = (new StreamFactory)->createStreamFromResource($resource);

// create a new uploaded file
$file = (new StreamFactory)->createStreamFromFile('/path/file');
$upload = (new UploadedFileFactory)->createUploadedFile($file);

// create a new uploaded file from server
$upload = (new UploadedFileFactory)->createUploadedFileFromServer($_FILES);

// create new uri from string
$uri = (new UriFactory)->createUri('http://example.com');

// create new uri from server
$uri = (new UriFactory)->createUriFromServer($_SERVER);