zeydkazanci03/laracurl 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zeydkazanci03/laracurl

Composer 安装命令:

composer require zeydkazanci03/laracurl

包简介

Laravel için gelişmiş ve kullanımı kolay Curl paketi

README 文档

README

Laravel 10+ için güçlü ve kullanımı kolay Curl paketi.

Özellikler

  • ✅ Tüm HTTP metodları (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
  • ✅ Fluent API ile kolay kullanım
  • ✅ JSON, Form Data, Multipart desteği
  • ✅ Dosya yükleme
  • ✅ Bearer Token ve Basic/Digest Authentication
  • ✅ Proxy desteği
  • ✅ Cookie yönetimi
  • ✅ SSL doğrulama kontrolü
  • ✅ Header yönetimi
  • ✅ Timeout ayarları
  • ✅ Yönlendirme kontrolü
  • ✅ Response helper metodları
  • ✅ Laravel Facade desteği

Kurulum

Composer ile paketi yükleyin:

composer require zeydkazanci03/laracurl

Laravel 10+ için otomatik olarak servis sağlayıcı kaydedilir.

Config Dosyasını Yayınlama (Opsiyonel)

php artisan vendor:publish --tag=laracurl-config

Temel Kullanım

GET İsteği

use Curl;

// Basit GET isteği
$response = Curl::get('https://api.example.com/users');
echo $response->response();

// Query parametreleri ile
$response = Curl::get('https://api.example.com/users', [
    'page' => 1,
    'limit' => 10
]);

// JSON olarak al
$data = $response->json();

POST İsteği

// JSON gönderme
$response = Curl::post('https://api.example.com/users')
    ->json([
        'name' => 'Zeyd Kazancı',
        'email' => 'zeyd@example.com'
    ])
    ->response();

// Form data gönderme
$response = Curl::post('https://api.example.com/login')
    ->form([
        'username' => 'zeyd',
        'password' => 'secret'
    ])
    ->response();

PUT/PATCH İsteği

$response = Curl::put('https://api.example.com/users/1')
    ->json([
        'name' => 'Yeni İsim'
    ])
    ->response();

$response = Curl::patch('https://api.example.com/users/1')
    ->json([
        'email' => 'yeni@example.com'
    ])
    ->response();

DELETE İsteği

$response = Curl::delete('https://api.example.com/users/1');

if ($response->successful()) {
    echo "Başarıyla silindi";
}

Gelişmiş Kullanım

Header Yönetimi

$response = Curl::get('https://api.example.com/data')
    ->header('X-Custom-Header', 'value')
    ->headers([
        'X-Another-Header' => 'value',
        'X-Third-Header' => 'value'
    ])
    ->response();

Authentication

Bearer Token

$response = Curl::get('https://api.example.com/protected')
    ->bearerToken('your-token-here')
    ->response();

Basic Authentication

$response = Curl::get('https://api.example.com/protected')
    ->basicAuth('username', 'password')
    ->response();

Digest Authentication

$response = Curl::get('https://api.example.com/protected')
    ->digestAuth('username', 'password')
    ->response();

Dosya Yükleme

$response = Curl::post('https://api.example.com/upload')
    ->attach('file', '/path/to/file.jpg', 'image/jpeg')
    ->attach('document', '/path/to/document.pdf')
    ->response();

// Ek form verileri ile
$response = Curl::post('https://api.example.com/upload')
    ->attach('avatar', '/path/to/avatar.jpg')
    ->multipart([
        'user_id' => 123,
        'description' => 'Profil fotoğrafı'
    ])
    ->response();

Timeout Ayarları

$response = Curl::get('https://api.example.com/slow-endpoint')
    ->timeout(60) // 60 saniye
    ->connectTimeout(10) // Bağlantı için 10 saniye
    ->response();

SSL Doğrulama

// SSL doğrulamayı kapat (development için)
$response = Curl::get('https://self-signed-cert.example.com')
    ->sslVerify(false)
    ->response();

Proxy Kullanımı

$response = Curl::get('https://api.example.com/data')
    ->proxy('proxy.example.com', 8080)
    ->response();

// Authentication ile
$response = Curl::get('https://api.example.com/data')
    ->proxy('proxy.example.com', 8080, 'username', 'password')
    ->response();

Cookie Yönetimi

// Cookie ekleme
$response = Curl::get('https://example.com')
    ->cookie('session_id', 'abc123')
    ->cookie('user_token', 'xyz789')
    ->response();

// Cookie dosyası kullanma
$response = Curl::get('https://example.com')
    ->cookieFile('/path/to/cookies.txt')
    ->response();

Yönlendirme Kontrolü

// Yönlendirmeleri takip etme
$response = Curl::get('https://example.com/redirect')
    ->followRedirects(true, 10) // Maksimum 10 yönlendirme
    ->response();

// Yönlendirmeleri devre dışı bırakma
$response = Curl::get('https://example.com/redirect')
    ->followRedirects(false)
    ->response();

User Agent ve Referer

$response = Curl::get('https://example.com')
    ->userAgent('MyCustomBot/1.0')
    ->referer('https://google.com')
    ->response();

Custom CURL Options

$response = Curl::get('https://example.com')
    ->setOption(CURLOPT_ENCODING, 'gzip')
    ->setOptions([
        CURLOPT_BUFFERSIZE => 4096,
        CURLOPT_FRESH_CONNECT => true
    ])
    ->response();

Response Metodları

Response Body

$response = Curl::get('https://api.example.com/data');

// Ham response
$body = $response->response();

// JSON olarak
$data = $response->json();

// Obje olarak
$object = $response->object();

// String olarak
$string = (string) $response;

Status Kontrolü

$response = Curl::get('https://api.example.com/data');

// HTTP status code
$statusCode = $response->status(); // 200, 404, 500, vb.

// Başarılı mı? (2xx)
if ($response->successful()) {
    echo "Başarılı!";
}

// Başarısız mı?
if ($response->failed()) {
    echo "Başarısız!";
}

// Client hatası mı? (4xx)
if ($response->clientError()) {
    echo "Client hatası";
}

// Server hatası mı? (5xx)
if ($response->serverError()) {
    echo "Server hatası";
}

Request Bilgileri

$response = Curl::get('https://api.example.com/data');

// Tüm bilgiler
$info = $response->info();

// Belirli bir bilgi
$totalTime = $response->info('total_time');
$downloadSize = $response->info('size_download');

// Response header'ları
$headers = $response->headers();

Hata Yönetimi

$response = Curl::get('https://api.example.com/data');

if ($response->failed()) {
    $errorMessage = $response->error();
    $errorNumber = $response->errno();
    
    echo "Hata: $errorMessage (Kod: $errorNumber)";
}

Dosyaya Kaydetme

$response = Curl::get('https://example.com/file.pdf');

// Dosyaya kaydet
$response->save('/path/to/save/file.pdf');

// Tarayıcıdan indir
$response->download('my-file.pdf');

Zincirleme Kullanım (Method Chaining)

$response = Curl::post('https://api.example.com/data')
    ->bearerToken('your-token')
    ->header('X-Custom-Header', 'value')
    ->timeout(30)
    ->sslVerify(false)
    ->json([
        'key' => 'value'
    ]);

if ($response->successful()) {
    $data = $response->json();
    // İşlemler...
}

Facade Olmadan Kullanım

use ZeydKazanci03\LaraCurl\CurlManager;

$curl = new CurlManager();
$response = $curl->get('https://api.example.com/data');

Bağımlılık Enjeksiyonu

use ZeydKazanci03\LaraCurl\CurlManager;

class UserService
{
    protected $curl;
    
    public function __construct(CurlManager $curl)
    {
        $this->curl = $curl;
    }
    
    public function getUsers()
    {
        return $this->curl
            ->get('https://api.example.com/users')
            ->json();
    }
}

Örnekler

API'den Veri Çekme

use Curl;

$response = Curl::get('https://jsonplaceholder.typicode.com/posts/1');

if ($response->successful()) {
    $post = $response->json();
    echo $post['title'];
}

API'ye Veri Gönderme

$response = Curl::post('https://jsonplaceholder.typicode.com/posts')
    ->json([
        'title' => 'Yeni Post',
        'body' => 'Post içeriği',
        'userId' => 1
    ]);

if ($response->successful()) {
    $newPost = $response->json();
    echo "Yeni post ID: " . $newPost['id'];
}

Kimlik Doğrulama ile İstek

$response = Curl::get('https://api.github.com/user')
    ->bearerToken('your-github-token');

if ($response->successful()) {
    $user = $response->json();
    echo "Merhaba, " . $user['name'];
}

Dosya İndirme

$response = Curl::get('https://example.com/large-file.zip')
    ->timeout(300); // 5 dakika

if ($response->successful()) {
    $response->save(storage_path('downloads/file.zip'));
    echo "Dosya indirildi!";
}

Form ile Dosya Yükleme

$response = Curl::post('https://api.example.com/upload')
    ->attach('image', storage_path('temp/photo.jpg'), 'image/jpeg')
    ->multipart([
        'title' => 'Tatil Fotoğrafı',
        'description' => '2024 yaz tatili',
        'category' => 'personal'
    ]);

if ($response->successful()) {
    echo "Dosya yüklendi!";
}

Lisans

MIT License

Destek

Herhangi bir sorun veya öneriniz için GitHub'da issue açabilirsiniz.

Geliştirici

Zeyd Kazancı

LaraCurl ile Laravel projelerinizde HTTP isteklerini kolayca yönetin! 🚀

zeydkazanci03/laracurl 适用场景与选型建议

zeydkazanci03/laracurl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「curl」 「http」 「request」 「laravel」 「zeydkazanci03」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 zeydkazanci03/laracurl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 zeydkazanci03/laracurl 我们能提供哪些服务?
定制开发 / 二次开发

基于 zeydkazanci03/laracurl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-26