Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 23 days ago
JSON representation
php class to send some requests
- Host: GitHub
- URL: https://github.com/arashabedii/requester
- Owner: ArashAbedii
- License: mit
- Created: 2021-02-13T11:33:53.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-11-26T10:51:04.000Z (12 months ago)
- Last Synced: 2024-10-14T02:01:17.097Z (23 days ago)
- Topics: api, curl, curlphp, http, https, php, php-curl, php-curl-library, php-library, php-request, rest-api
- Language: PHP
- Homepage:
- Size: 46.9 KB
- Stars: 5
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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;```