Skip to content

Commit 1267e0b

Browse files
Upgrade SOLAPI PHP SDK to version 5.1.0
- Transitioned from raw CURL to PSR-18 compatible HTTP client for improved security and flexibility. - Added new dependencies: `psr/http-client`, `psr/http-message`, and `nyholm/psr7`. - Introduced `HttpClient` class for handling HTTP requests and responses. - Deprecated `CurlException` in favor of `HttpException` for better error handling. - Added documentation on migration rationale from CURL to PSR-18.
1 parent e35469d commit 1267e0b

7 files changed

Lines changed: 615 additions & 66 deletions

File tree

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "solapi/sdk",
33
"description": "SOLAPI SDK for PHP",
4-
"version": "5.0.6",
4+
"version": "5.1.0",
55
"type": "library",
66
"license": "MIT",
77
"autoload": {
@@ -41,7 +41,9 @@
4141
"homepage": "https://solapi.com",
4242
"require": {
4343
"php": ">=7.1",
44-
"ext-curl": "*",
45-
"ext-json": "*"
44+
"ext-json": "*",
45+
"psr/http-client": "^1.0",
46+
"psr/http-message": "^1.0 || ^2.0",
47+
"nyholm/psr7": "^1.5"
4648
}
4749
}

composer.lock

Lines changed: 242 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/curl-migration-rationale.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# CURL에서 PSR-18 HTTP 클라이언트로의 마이그레이션
2+
3+
## 개요
4+
5+
SOLAPI PHP SDK v5.1.0부터 HTTP 클라이언트가 raw CURL에서 PSR-18 호환 구현으로 변경되었습니다.
6+
7+
## 기존 CURL 구현의 문제점
8+
9+
### 1. 보안 취약점: SSL 인증서 검증 비활성화
10+
11+
```php
12+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
13+
```
14+
15+
- MITM 공격에 취약
16+
- PCI-DSS, SOC2 등 보안 규정 위반 가능성
17+
18+
### 2. 타임아웃 설정 부재
19+
20+
- `CURLOPT_TIMEOUT`, `CURLOPT_CONNECTTIMEOUT` 미설정
21+
- 서버 무응답 시 무한 대기
22+
23+
### 3. ext-curl 필수 의존성
24+
25+
- 공유 호스팅, Docker, Serverless 환경에서 문제 발생 가능
26+
- 환경별 호환성 이슈
27+
28+
### 4. Guzzle 버전 충돌
29+
30+
- Guzzle 6.x 사용 프로젝트와 충돌
31+
- Guzzle 7.x만 지원 시 기존 사용자 업그레이드 강제
32+
33+
---
34+
35+
## 새로운 PSR-18 기반 구현
36+
37+
### 장점
38+
39+
| 항목 | 설명 |
40+
|------|------|
41+
| **Guzzle 독립적** | Guzzle 6.x, 7.x 모두와 충돌 없음 |
42+
| **PSR-18 호환** | 표준 인터페이스로 다른 HTTP 클라이언트 주입 가능 |
43+
| **순수 PHP** | ext-curl 불필요, PHP streams 사용 |
44+
| **보안 강화** | SSL 검증 기본 활성화 |
45+
| **타임아웃 설정** | 30초 기본 타임아웃 |
46+
47+
### 의존성
48+
49+
```json
50+
{
51+
"require": {
52+
"php": ">=7.1",
53+
"psr/http-client": "^1.0",
54+
"psr/http-message": "^1.0 || ^2.0",
55+
"nyholm/psr7": "^1.5"
56+
}
57+
}
58+
```
59+
60+
- `psr/http-client`: PSR-18 HTTP Client 인터페이스
61+
- `psr/http-message`: PSR-7 HTTP Message 인터페이스
62+
- `nyholm/psr7`: 경량 PSR-7 구현 (126M+ 다운로드)
63+
64+
---
65+
66+
## 커스텀 HTTP 클라이언트 사용
67+
68+
Guzzle이나 다른 PSR-18 호환 클라이언트를 사용하려면:
69+
70+
```php
71+
use GuzzleHttp\Client as GuzzleClient;
72+
use Nurigo\Solapi\Libraries\Fetcher;
73+
74+
// Guzzle 클라이언트 생성
75+
$guzzle = new GuzzleClient([
76+
'timeout' => 60,
77+
'verify' => true,
78+
]);
79+
80+
// Fetcher에 주입
81+
$fetcher = new Fetcher('API_KEY', 'API_SECRET', $guzzle);
82+
```
83+
84+
### 지원되는 PSR-18 클라이언트
85+
86+
- Guzzle 7.x (`guzzlehttp/guzzle`)
87+
- Symfony HttpClient (`symfony/http-client`)
88+
- 기타 PSR-18 호환 클라이언트
89+
90+
---
91+
92+
## 하위 호환성
93+
94+
### 변경 없음
95+
96+
- `SolapiMessageService`의 모든 public 메서드
97+
- `Message` fluent builder
98+
- 예외 처리 (`catch (CurlException $e)`)
99+
100+
### 변경됨
101+
102+
| 항목 | 이전 | 이후 |
103+
|------|------|------|
104+
| PHP 버전 | >= 7.1 | >= 7.1 (유지) |
105+
| HTTP 클라이언트 | raw CURL | PSR-18 (PHP streams) |
106+
| ext-curl | 필수 | 불필요 |
107+
| SSL 검증 | 비활성화 | 활성화 |
108+
| 타임아웃 | 없음 | 30초 |
109+
110+
---
111+
112+
## 참고 자료
113+
114+
- [PSR-18: HTTP Client](https://www.php-fig.org/psr/psr-18/)
115+
- [PSR-7: HTTP Message Interface](https://www.php-fig.org/psr/psr-7/)
116+
- [nyholm/psr7](https://github.com/Nyholm/psr7)

0 commit comments

Comments
 (0)