|
@@ -1,28 +1,22 @@
|
|
|
-ixudra/curl
|
|
|
+hugh/curl
|
|
|
================
|
|
|
+## [[Fork from](https://github.com/ixudra/curl.git)][](https://packagist.org/packages/ixudra/curl)[](https://packagist.org/packages/ixudra/curl)
|
|
|
|
|
|
-[](https://packagist.org/packages/ixudra/curl)
|
|
|
-[]()
|
|
|
-[](https://packagist.org/packages/ixudra/curl)
|
|
|
+Custom PHP cURL library for the Laravel framework - developed by [Ixudra](http://ixudra.be) - re-developed by [Hugh Harlequin](https://git.hugh2113.com/hugh).
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-Custom PHP cURL library for the Laravel framework - developed by [Ixudra](http://ixudra.be).
|
|
|
-
|
|
|
-The package provides an easy interface for sending cURL requests from your PHP web application. The package provides an
|
|
|
-intuitive, fluent interface similar the Laravel query builder to easily configure the request. Additionally, There are
|
|
|
+The package provides an easy interface for sending cURL requests from your PHP web application. The package provides an
|
|
|
+intuitive, fluent interface similar the Laravel query builder to easily configure the request. Additionally, There are
|
|
|
several utility methods that allow you to easily add certain options to the request. This makes it easier to create and
|
|
|
use cURL requests and also makes your code more comprehensible.
|
|
|
|
|
|
-The provided functionality is completely framework-independent but also contains a Laravel service provider for easy
|
|
|
+The provided functionality is completely framework-independent but also contains a Laravel service provider for easy
|
|
|
integration into your Laravel project.
|
|
|
|
|
|
|
|
|
- > Note before posting an issue: When posting an issue for the package, always be sure to provide as much information
|
|
|
- > regarding the request as possible. This includes the example cURL request you are trying to transfer into the package
|
|
|
- > syntax, your actual package syntax (the full request) and (if possible) an example URL I can use to test the request
|
|
|
- > myself if need be.
|
|
|
+> Note before posting an issue: When posting an issue for the package, always be sure to provide as much information
|
|
|
+> regarding the request as possible. This includes the example cURL request you are trying to transfer into the package
|
|
|
+> syntax, your actual package syntax (the full request) and (if possible) an example URL I can use to test the request
|
|
|
+> myself if need be.
|
|
|
|
|
|
|
|
|
|
|
@@ -32,17 +26,24 @@ integration into your Laravel project.
|
|
|
Pull this package in through Composer.
|
|
|
|
|
|
```js
|
|
|
+ "repositories": [
|
|
|
+ {
|
|
|
+ "type": "vcs",
|
|
|
+ "url": "https://git.hugh2113.com/hugh/curl.git"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ ...
|
|
|
|
|
|
{
|
|
|
"require": {
|
|
|
- "ixudra/curl": "6.*"
|
|
|
+ "hugh/curl": "6.*"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
or run in terminal:
|
|
|
-`composer require ixudra/curl`
|
|
|
+`composer require hugh/curl`
|
|
|
|
|
|
### Laravel 5.5+ Integration
|
|
|
|
|
@@ -58,7 +59,7 @@ Add the service provider to your `config/app.php` file:
|
|
|
'providers' => array(
|
|
|
|
|
|
//...
|
|
|
- Ixudra\Curl\CurlServiceProvider::class,
|
|
|
+ Hugh\Curl\CurlServiceProvider::class,
|
|
|
|
|
|
),
|
|
|
|
|
@@ -71,7 +72,7 @@ Add the facade to your `config/app.php` file:
|
|
|
'aliases' => array(
|
|
|
|
|
|
//...
|
|
|
- 'Curl' => Ixudra\Curl\Facades\Curl::class,
|
|
|
+ 'Curl' => Hugh\Curl\Facades\Curl::class,
|
|
|
|
|
|
),
|
|
|
|
|
@@ -87,7 +88,7 @@ Add the service provider to your `app/config/app.php` file:
|
|
|
'providers' => array(
|
|
|
|
|
|
//...
|
|
|
- 'Ixudra\Curl\CurlServiceProvider',
|
|
|
+ 'Hugh\Curl\CurlServiceProvider',
|
|
|
|
|
|
),
|
|
|
|
|
@@ -100,7 +101,7 @@ Add the facade to your `app/config/app.php` file:
|
|
|
'facades' => array(
|
|
|
|
|
|
//...
|
|
|
- 'Curl' => 'Ixudra\Curl\Facades\Curl',
|
|
|
+ 'Curl' => 'Hugh\Curl\Facades\Curl',
|
|
|
|
|
|
),
|
|
|
|
|
@@ -117,7 +118,7 @@ $app->withFacades();
|
|
|
|
|
|
Then, register your class alias:
|
|
|
```
|
|
|
-class_alias('Ixudra\Curl\Facades\Curl', 'Curl');
|
|
|
+class_alias('Hugh\Curl\Facades\Curl', 'Curl');
|
|
|
```
|
|
|
|
|
|
Finally, you have to register your ServiceProvider (around line 70-80):
|
|
@@ -137,7 +138,7 @@ Finally, you have to register your ServiceProvider (around line 70-80):
|
|
|
// $app->register('App\Providers\AppServiceProvider');
|
|
|
|
|
|
// Package service providers
|
|
|
-$app->register(Ixudra\Curl\CurlServiceProvider::class);
|
|
|
+$app->register(Hugh\Curl\CurlServiceProvider::class);
|
|
|
```
|
|
|
|
|
|
|
|
@@ -147,7 +148,7 @@ Create a new instance of the `CurlService` where you would like to use the packa
|
|
|
|
|
|
```php
|
|
|
|
|
|
- $curlService = new \Ixudra\Curl\CurlService();
|
|
|
+ $curlService = new \Hugh\Curl\CurlService();
|
|
|
|
|
|
```
|
|
|
|
|
@@ -169,7 +170,7 @@ In order to send a `GET` request, you need to use the `get()` method that is pro
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to: http://www.foo.com/bar
|
|
|
$response = Curl::to('http://www.foo.com/bar')
|
|
@@ -195,7 +196,7 @@ Post requests work similar to `GET` requests, but use the `post()` method instea
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a POST request to: http://www.foo.com/bar
|
|
|
$response = Curl::to('http://www.foo.com/bar')
|
|
@@ -227,7 +228,7 @@ Put requests work similar to `POST` requests, but use the `put()` method instead
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a PUT request to: http://www.foo.com/bar/1 with arguments 'foz' = 'baz' using JSON
|
|
|
$response = Curl::to('http://www.foo.com/bar/1')
|
|
@@ -244,7 +245,7 @@ Patch requests work similar to `POST` requests, but use the `patch()` method ins
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a PATCH request to: http://www.foo.com/bar/1 with arguments 'foz' = 'baz' using JSON
|
|
|
$response = Curl::to('http://www.foo.com/bar/1')
|
|
@@ -261,7 +262,7 @@ Delete requests work similar to `GET` requests, but use the `delete()` method in
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a DELETE request to: http://www.foo.com/bar/1 using JSON
|
|
|
$response = Curl::to('http://www.foo.com/bar/1')
|
|
@@ -277,7 +278,7 @@ HEAD requests work similar to `GET` requests, but use the `head()` method instea
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a HEAD request to: http://www.foo.com/bar/1
|
|
|
$response = Curl::to('http://www.foo.com/bar/1')
|
|
@@ -297,7 +298,7 @@ Sending custom headers is easy with the `withHeader()` method. Multiple calls ca
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to: http://www.foo.com/bar with 2 custom headers
|
|
|
$response = Curl::to('http://foo.com/bar')
|
|
@@ -311,7 +312,7 @@ Alternatively, you can use the `withHeaders()` to combine multiple headers into
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to: http://www.foo.com/bar with 2 custom headers
|
|
|
$response = Curl::to('http://foo.com/bar')
|
|
@@ -324,7 +325,7 @@ You can also use key-value when using the `withHeaders()` method:
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to: http://www.foo.com/bar with 2 custom headers
|
|
|
$response = Curl::to('http://foo.com/bar')
|
|
@@ -337,7 +338,7 @@ For (bearer) authorization headers, you can also use specific utility methods:
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to: http://www.foo.com/bar with "Authorization: 123" header
|
|
|
$response = Curl::to('http://foo.com/bar')
|
|
@@ -351,8 +352,27 @@ For (bearer) authorization headers, you can also use specific utility methods:
|
|
|
|
|
|
```
|
|
|
|
|
|
- > Note that headers will override each other if you add the same header more than once.
|
|
|
+> Note that headers will override each other if you add the same header more than once.
|
|
|
+
|
|
|
+### With Encoding content
|
|
|
|
|
|
+Sending Encoding content is easy with `withEncoding()` method. If empty pass , default is `gzip,deflate`
|
|
|
+
|
|
|
+```php
|
|
|
+
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
+
|
|
|
+ // Send a GET request to: http://www.foo.com/bar with encoding gzip,deflate
|
|
|
+ $response = Curl::to('http://foo.com/bar')
|
|
|
+ ->withEncoding()
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ // Send a GET request to: http://www.foo.com/bar with encoding gzip
|
|
|
+ $response = Curl::to('http://foo.com/bar')
|
|
|
+ ->withEncoding('gzip')
|
|
|
+ ->get();
|
|
|
+
|
|
|
+```
|
|
|
|
|
|
### Specifying the content type
|
|
|
|
|
@@ -360,7 +380,7 @@ Sending custom headers is easy with the `withContentType()` method. Multiple cal
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to: http://www.foo.com/bar with a json content type
|
|
|
$response = Curl::to('http://foo.com/bar')
|
|
@@ -384,7 +404,7 @@ Optional parameters will be ignored if not filled in.
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to: http://www.foo.com/bar with a json content type
|
|
|
$response = Curl::to('http://foo.com/bar')
|
|
@@ -400,7 +420,7 @@ For sending files via a POST request, you can use the `withFile` method to corre
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
$response = Curl::to('http://foo.com/bar')
|
|
|
->withData( array( 'Foo' => 'Bar' ) )
|
|
@@ -422,7 +442,7 @@ For downloading a file, you can use the `download()` method:
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Download an image from: file http://www.foo.com/bar.png
|
|
|
$response = Curl::to('http://foo.com/bar.png')
|
|
@@ -436,12 +456,12 @@ For downloading a file, you can use the `download()` method:
|
|
|
|
|
|
By default, the package will only return the content of the request. In some cases, it might also be useful to know
|
|
|
additional request information, such as the HTTP status code and error messages should they occur. In this case, you
|
|
|
-can use the `returnResponseObject()` method, which will return an stdClass that contains additional information as
|
|
|
+can use the `returnResponseObject()` method, which will return an stdClass that contains additional information as
|
|
|
well as the response content:
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to http://www.foo.com/bar and return a response object with additional information
|
|
|
$response = Curl::to('http://www.foo.com/bar')
|
|
@@ -469,7 +489,7 @@ In some cases it might be relevant to return the response headers back to the us
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to http://www.foo.com/bar and return a response object with additional information including response headers
|
|
|
$response = Curl::to('http://www.foo.com/bar')
|
|
@@ -507,7 +527,7 @@ This method uses one parameter, which is the name of the file in which the debug
|
|
|
|
|
|
```php
|
|
|
|
|
|
- use Ixudra\Curl\Facades\Curl;
|
|
|
+ use Hugh\Curl\Facades\Curl;
|
|
|
|
|
|
// Send a GET request to http://www.foo.com/bar and log debug information in /path/to/dir/logFile.txt
|
|
|
$response = Curl::to('http://www.foo.com/bar')
|
|
@@ -542,9 +562,10 @@ any validation on the cURL options. Additional information about available cURL
|
|
|
| setCookieFile() | none | Set a file to read cookies from |
|
|
|
| setCookieJar() | none | Set a file to store cookies in |
|
|
|
| withOption() | none | Generic method to add any cURL option to the request |
|
|
|
+| withEncoding() | gzip,deflate | Set content encoding by |
|
|
|
|
|
|
-For specific information regarding parameters and return types, I encourage you to take a look at
|
|
|
-`ixudra\curl\src\Ixudra\Curl\Builder.php`. This class has extensive doc blocks that contain all the necessary information
|
|
|
+For specific information regarding parameters and return types, I encourage you to take a look at
|
|
|
+`hugh\curl\src\Hugh\Curl\Builder.php`. This class has extensive doc blocks that contain all the necessary information
|
|
|
for each specific method.
|
|
|
|
|
|
|
|
@@ -556,7 +577,7 @@ use the facades to access the `CurlService`.
|
|
|
|
|
|
```php
|
|
|
|
|
|
- $curlService = new \Ixudra\Curl\CurlService();
|
|
|
+ $curlService = new \Hugh\Curl\CurlService();
|
|
|
|
|
|
// Send a GET request to: http://www.foo.com/bar
|
|
|
$response = $curlService->to('http://www.foo.com/bar')
|
|
@@ -585,8 +606,8 @@ use the facades to access the `CurlService`.
|
|
|
|
|
|
## Planning
|
|
|
|
|
|
- - Add additional utility methods for other cURL options
|
|
|
- - Add contract to allow different HTTP providers such as Guzzle
|
|
|
+- Add additional utility methods for other cURL options
|
|
|
+- Add contract to allow different HTTP providers such as Guzzle
|
|
|
|
|
|
|
|
|
|
|
@@ -606,12 +627,14 @@ This package is open-sourced software licensed under the [MIT license](http://op
|
|
|
|
|
|
|
|
|
## Contact
|
|
|
-
|
|
|
-For package questions, bug, suggestions and/or feature requests, please use the Github issue system and/or submit a pull request. When submitting an issue, always provide a detailed explanation of your problem, any response or feedback your get, log messages that might be relevant as well as a source code example that demonstrates the problem. If not, I will most likely not be able to help you with your problem. Please review the [contribution guidelines](https://github.com/ixudra/curl/blob/master/CONTRIBUTING.md) before submitting your issue or pull request.
|
|
|
-
|
|
|
-For any other questions, feel free to use the credentials listed below:
|
|
|
+For any other questions, feel free to use the credentials listed below:
|
|
|
|
|
|
Jan Oris (developer)
|
|
|
|
|
|
- Email: [email protected]
|
|
|
-- Telephone: +32 496 94 20 57
|
|
|
+- Telephone: +32 496 94 20 57
|
|
|
+
|
|
|
+Hugh Harlequin (re-developer)
|
|
|
+
|
|
|
+- Email: [email protected]
|
|
|
+- Telephone: +886 920 970 710
|