Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arashabedii/requester

php class to send some requests
https://github.com/arashabedii/requester

api curl curlphp http https php php-curl php-curl-library php-library php-request rest-api

Last synced: about 3 hours ago
JSON representation

php class to send some requests

Awesome Lists containing this project

README

        

# Request
## php class to send requests
### Simple & Fast & Very light


### features

send GET , POST , PUT , PATCH , DELETE requests

send params in simple array

send headers in simple array

requests auto logging

error logger

send request without waiting for response




## Install via composer


Go to your project root directory and run this command in terminal:

```
composer require arashabedii/requester
```




## usage
```
# to enable request logging just pass $logger=true to send method
Request::send([string] url, [array] or [string] or [file context] params, [string] request type , [array] headers,[bool] logger);
```



#### at first include autoload.php file to your project file

```
require 'vendor/autoload.php';
```
#### after you can call Request::send() to send your requests.



## examples:


**SEND GET REQUEST**

```PHP
1,
];
$headers=[
'Content-Type'=>'application/json',
];
$logger=true; //enable or diable logging requests
$response=Request::send($url,$params,$method,$headers,$logger);

//show headers
echo $response->headers;
//show response body
echo $response->body;

```


**SEND POST REQUEST**

```PHP
'myname',
'job'=>'myjob'
];
$headers=[
'Content-Type'=>'application/json',
];
$logger=false; //enable or diable logging requests
$response=Request::send($url,$params,$method,$headers,$logger);

//show headers
echo $response->headers;
//show response body
echo $response->body;

```


**SEND PUT REQUEST**

```PHP
'myname2',
'job'=>'myjob2'
];
$headers=[
'Content-Type'=>'application/json',
];
$logger=false; //enable or diable logging requests
$response=Request::send($url,$params,$method,$headers,$logger);

//show headers
echo $response->headers;
//show response body
echo $response->body;

```


**SEND PATCH REQUEST**

```PHP
'myname2',
'job'=>'myjob2'
];
$headers=[
'Content-Type'=>'application/json',
];
$logger=false; //enable or diable logging requests
$response=Request::send($url,$params,$method,$headers,$logger);

//show headers
echo $response->headers;
//show response body
echo $response->body;

```


**SEND DELETE REQUEST**

```PHP
'application/json',
];
$logger=true; //enable or diable logging requests

$response=Request::send($url,$params,$method,$headers,$logger);

//show headers
echo $response->headers;
//show response body
echo $response->body;

```