Giter VIP home page Giter VIP logo

requester's Introduction

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
use ArashAbedii\Request;

require './vendor/autoload.php';

#------------------------------SIMPLE GET REQUEST---------------------------
$url="https://reqres.in/api/users";
$method='GET';
$params=[
   'delay'=>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
use ArashAbedii\Request;

require './vendor/autoload.php';

#------------------------------SIMPLE POST REQUEST---------------------------
$url="https://reqres.in/api/users";
$method='POST';
$params=[
   'name'=>'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
use ArashAbedii\Request;

require './vendor/autoload.php';

#------------------------------SIMPLE PUT REQUEST---------------------------
$url="https://reqres.in/api/users/2";
$method='PUT';
$params=[
   'name'=>'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
use ArashAbedii\Request;

require './vendor/autoload.php';

#------------------------------SIMPLE PATCH REQUEST---------------------------
$url="https://reqres.in/api/users/2";
$method='PATCH';
$params=[
   'name'=>'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
use ArashAbedii\Request;

require './vendor/autoload.php';

#------------------------------SIMPLE DELETE REQUEST---------------------------
$url="https://reqres.in/api/users/2";
$method='DELETE';
$params=[
   //no params or your params
];
$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;



requester's People

Contributors

arashabedii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.