PHP code example of davidecesarano / embryo-client

1. Go to this page and download the library: Download davidecesarano/embryo-client 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-client example snippets


use Embryo\Http\Client\ClientFactory;

$http = new ClientFactory;
$response = $http->get('https://example.com/');

$response = $http->post('https://example.com/users', [
    'name' => 'Davide',
    'surname' => 'Cesarano'
]);

$response = $http
    ->withHeaders([
        'X-First' => 'foo',
        'X-Second' => 'bar'
    ])
    ->post('https://example.com/users', [
        'name' => 'Davide',
        'surname' => 'Cesarano'
    ]);

$response = $http
    ->withToken('token')
    ->post('https://example.com/users', [
        'name' => 'Davide',
        'surname' => 'Cesarano'
    ]);

$response = $http
    ->withJson()
    ->post('https://example.com/users', [
        'name' => 'Davide',
        'surname' => 'Cesarano'
    ]);

$response = $http
    ->withFile('file1', '/path/to/file1')
    ->withFile('file2', '/path/to/file2')
    ->post('https://example.com/upload');

$response = $http
    ->withTimeout(30)
    ->get('https://example.com/users');