nolikein/laravel-curl-client
最新稳定版本:1.0.1
Composer 安装命令:
composer require nolikein/laravel-curl-client
包简介
An adapter to Laravel of the Nolikein Curl Client
README 文档
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.
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-10