Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uestla/curly
Simple PHP cURL wrapper class
https://github.com/uestla/curly
cookies curl php
Last synced: about 2 months ago
JSON representation
Simple PHP cURL wrapper class
- Host: GitHub
- URL: https://github.com/uestla/curly
- Owner: uestla
- Created: 2016-07-02T07:03:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-05T01:07:27.000Z (almost 8 years ago)
- Last Synced: 2024-11-11T13:23:06.733Z (about 2 months ago)
- Topics: cookies, curl, php
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Curly\Curl
Single-class PHP cURL wrapper
## Installation
```
$ composer require uestla/curly
```## Basic usage
```php
use Curly\Curl;// initialize first - set temp directory for cookie files
Curl::initialize(__DIR__ . '/temp');// GET request
$html = Curl::get($url);// GET request with no auto-redirect
$html = Curl::get($url, FALSE);// POST request with values
$html = Curl::post($url, [
'foo' => 'bar',
'hello' => 'world',
'file' => new CURLFile($path),
]);// HEAD request
$status = Curl::ping($url);// last response info
$info = Curl::getInfo();// or single info field
$httpCode = Curl::getInfo('http_code');
```### Settings
- `Curly\Curl::$userAgent` - string with UserAgent header sent with each request (default: [here](https://github.com/uestla/curly/blob/master/src/Curly/Curl.php#L20-L21))
- `Curly\Curl::$maxRedirects` - max. number of redirects when auto-redirect is `TRUE` (default: 6)
### Cookies
`Curly` offers basic cookie-reading support:
```php
// all cookies across all domains
$cookies = Curl::getCookies();// cookies for specific domain
$cookies = Curl::getCookies('http://example.com');// cookies for specific domain and path
$cookies = Curl::getCookies('http://example.com/foo/bar');
```