PHP code example of anshu-krishna / web-fetcher

1. Go to this page and download the library: Download anshu-krishna/web-fetcher 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/ */

    

anshu-krishna / web-fetcher example snippets



use Krishna\WebFetcher\Server;

/*
new Server(
	?string $protocal = null, // Default: http, Options: http, https
	?string $domain = null, // Default: Same as current domain
	?string $path = null, // Default: Same as current path
)
*/
$server = new Server();

/*
There are two ways to make a request:

$server->get(
	string $file,
	?array $params = null,
	?array $headers = null
): FetchResult

$server->post(
	string $file,
	?array $params = null,
	?array $headers = null
): FetchResult
*/

$result = $server->get('index.php', ['id' => 1]);

var_dump($result);

/*
FetchResult {
	string $uri, // URI of the request
	?array $params, // Parameters of the request
	array $headers, // Headers of the request and response
	$response, // Response of the request
	?string $error_msg // Error message if response is not received
}
*/