https://github.com/zhusaidong/curlite
a light-weight php curl
https://github.com/zhusaidong/curlite
curl light-weight php
Last synced: 11 days ago
JSON representation
a light-weight php curl
- Host: GitHub
- URL: https://github.com/zhusaidong/curlite
- Owner: zhusaidong
- License: bsd-2-clause
- Created: 2017-12-18T03:26:51.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-30T06:08:51.000Z (almost 7 years ago)
- Last Synced: 2025-07-25T05:48:57.602Z (6 months ago)
- Topics: curl, light-weight, php
- Language: PHP
- Homepage: https://github.com/zhusaidong/curlite
- Size: 18.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CurLite
## About
### a Light-weight php curl
## Usage
```php
composer require zhusaidong/curlite
```
## Examples
```php
require_once './vendor/autoload.php';
use zhusaidong\CurLite\Request,zhusaidong\CurLite\Curl;
$request = new Request('https://github.com/search');
$request->postFields = ['q'=>'php curl','type'=>''];
$request->referer = 'https://github.com/';
$cl = new Curl($request);
$response = $cl->getResponse();
//if curl successed, the `$response->error` will equal `FALSE`.
if($response->error === FALSE)
{
echo $response->body;
}
else
{
echo 'error:'.$response->error;
}
```
## Available Properties
### Response Properties
```php
/**
* @var array $header response header
*/
$header = [];
/**
* @var string $body response body
*/
$body = '';
/**
* @var int $httpCode http code
*/
$httpCode = '';
/**
* @var string $cookie cookie
*/
$cookie = '';
/**
* @var array $serverInfo server info
*/
$serverInfo = [];
/**
* @var string|booean $error error msg, if curl successed, the $error is FALSE
*/
$error = '';
```
### Request Properties
```php
/**
* @const method get
*/
const METHOD_GET = 1;
/**
* @const method post
*/
const METHOD_POST = 2;
/**
* @var string $url request url
*/
$url = '';
/**
* @var int $method request method, default is GET
*/
$method = self::METHOD_GET;
/**
* @var array $postFields request post data
*/
$postFields = [];
/**
* @var array $header request header
*/
$header = [];
/**
* @var string $referer request referer
*/
$referer = '';
/**
* @var string $cookie cookie
*/
$cookie = '';
/**
* @var string $userAgent user-agent
*/
$userAgent = '';
/**
* @var boolean $isRandomIP is curl use random IP, default is FALSE
*/
$isRandomIP = FALSE;
/**
* @var string $caPath cafile path
*/
$caPath = '';
/**
* @var int $timeout request timeout
*/
$timeout = 3;
/**
* @var int $followLocation follow the location,
* set it zero can intercept the redirect
*/
$followLocation = 1;
```