nolikein / laravel-curl-client
An adapter to Laravel of the Nolikein Curl Client
Requires
- nolikein/curl-client: ^1.0
Requires (Dev)
- laravel/framework: ^12.20
This package is auto-updated.
Last update: 2025-07-11 16:50:22 UTC
README
Presentation
This is a Laravel wrapper of the Curl Client librairy.
Installation
You need to use composer to install the librairy.
composer require nolikein/laravel-curl-client ^1.0
Publishing the configuration file
To become able to configure you curl clients, run the command bellow:
php artisan vendor:publish --tag curl-client-config
Usage
Here is the most basic way of use (with some secure things)
use Nolikein\CurlClient\CurlClient;
use Nolikein\CurlClient\Exception\CurlException;
try {
/** @var \Nolikein\CurlClient\Response\Response $response */
$response = app('curl-client')->get('https://custom-url.org');
echo $response->getContent() ?? '';
} catch(CurlException $e) {
report($e);
}
The code app('curl-client')
retrieve the curl client from the service container. It does not have any configuration by default. See config/curl.php
for that. Let's take a look bellow:
return [
'clients' => [
'default' => [
'curl' => Curl::class,
'client' => CurlClient::class,
],
],
'services' => [
'curl-client' => 'default'
],
This code means there is a client named "default" that using the default Curl Client that iteself use the default Curl class. See this for more explaination about how the librairy works.
You also see a "services" part that will inject automatically the "default" client in the service container by the "curl-client" name.
List of available configurations
// ...
return [
'clients' => [
'my-custom-client' => [
// The low level programming class
'curl' => Curl::class,
// The high level programming class that use the "curl class".
'client' => CurlClient::class,
// All the things bellow are optional
'authentication' => [
// Supported type: Bearer
'type' => env('APP_TOKEN_TYPE', 'Bearer'),
'value' => env('APP_TOKEN', ''),
],
'certificate' => [
'path' => env('APP_CERTIFICATE_PATH', storage_path('certificate/filename.pem')),
],
'proxy' => [
'address' => env('APP_PROXY_URL', ''),
'tunnel' => true, // Using proxy tunneling. This is an optional argument
],
],
],
Licence
Contributing
You can open a ticket, make a pull request or contact me.