anshu-krishna / web-fetcher
Make GET or POST requests to any local or remote server. Primary goal is to be able to fetch data from REST APIs.
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/anshu-krishna/web-fetcher
Requires
- php: >=8.0.0
README
Make GET or POST requests to any local or remote server. Primary goal is to be able to fetch data from REST APIs.
Installation
composer require anshu-krishna/web-fetcher
Example:
<?php 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 } */