Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 161 | All time: 8,954 This week: 146 |
Version | License | PHP version | Categories | |||
php-http-client 1.0 | MIT/X Consortium ... | 7.0 | Networking, HTTP, PHP 5 |
Description | Author | |||||||||||||||||||||||
This package can process and send HTTP requests to Web servers. |
|
<?php |
http-client is the php package. It provides the ability to manage and parse request object. It also provides support for HTTP client transactions via cURL.
run this command
## BASIC USAGE
### The request object, GET example
Let's use a GET request with the URL '/index.php?var=value'
<?php require '../vendor/autoload.php';
$request = new Lablnet\Request();
// Get the value of _GET['var'] $var = $request->getQuery('var'); //it print the get request var_dump($var);
### The request object, POST example
Let's use a POST request.
// Get the value of $_POST['id'] if ($request->isPost()) {
$id = $request->getPost('id');
}
### Creating a response object
//Response $config = [
'code' => 200,
'headers' => [
'Content-Type' => 'text/html'
]
];
$response = new Lablnet\Response($config); $response->setBody('This is a plain text file.');
$response->send();
### Simple response redirect
//Redirect to other page/site. (new Lablnet\Redirect('https://zestframework.xyz/'));
### Using the cURL client
//Using the cURL client //Send request to https://zestframework.xyz login page with post method $request = $request->curl("https://zestframework.xyz/account/login/action","POST"); //Set transfer and return header $request->setReturnHeader(true)->setReturnTransfer(true); //Set the fields $request->setFields([
'username' => 'your-username',
'password' => 'your-password'
]); //Send the request $request->send(); // return => 200 $statusCode = $request->getCode(); // Display the body of the returned response echo "<br\>".$request->getBody();
Files (20) |
File | Role | Description | ||
---|---|---|---|---|
example (1 file) | ||||
src (11 files, 1 directory) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
readme.md | Doc. | Readme |
Files (20) | / | src |
File | Role | Description | ||
---|---|---|---|---|
Clients (4 files) | ||||
Headers.php | Class | Class source | ||
HTTP.php | Class | Class source | ||
Message.php | Class | Class source | ||
Redirect.php | Class | Class source | ||
Request.php | Class | Class source | ||
Response.php | Class | Class source | ||
ServerRequest.php | Class | Class source | ||
StatusCode.php | Class | Class source | ||
UploadedFile.php | Class | Class source | ||
Uri.php | Class | Class source | ||
ValidProtocolVersions.php | Class | Class source |
Files (20) | / | src | / | Clients |
File | Role | Description |
---|---|---|
AbstractClient.php | Class | Class source |
Client.php | Class | Class source |
CURL.php | Class | Class source |
Stream.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.