Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mateodioev/request
https://github.com/mateodioev/request
curl php requests
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mateodioev/request
- Owner: Mateodioev
- Created: 2022-03-02T21:46:18.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-12T21:24:31.000Z (11 months ago)
- Last Synced: 2024-10-14T02:01:17.179Z (2 months ago)
- Topics: curl, php, requests
- Language: PHP
- Homepage:
- Size: 43 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Easy curl
## Installation
Github:
```bash
git clone https://github.com/Mateodioev/request
cd request
composer install
```Composer:
```bash
composer require mateodioev/request
```## Usage
```php
require 'path/to/vendor/autoload.php';use Mateodioev\Request\Request;
# Start request
$req = new Request;
$req->Init($url, $curlopt_options); // $curlopt_options is opcional$req->setMethod('GET'); // GET, HEAD, POST, PUT, DELETE, PATCH
# Start request static
$req = Request::http_method_name($url, $curlopt_options);# Run request
$res = $req->Run($endpoint); // $endpoint is optional
echo $res
```## Request Response
```php
$req = Request::GET('https://netotf.space/v1/api');
$res = $req->Run('/http-cat/200');
$res->toJson(true); // Parse body responde to json
// Headers info
$res->getHeaderRequest('Host')[0];
$res->getHeaderResponse('x-author')[0];$res->setDebug(true); // Print all request info
echo $res // Print
```
![example output](https://i.imgur.com/9gCymkL.png)