|
| 1 | +# SOLAPI PHP SDK |
| 2 | + |
| 3 | +**Generated:** 2026-01-21 |
| 4 | +**Commit:** b68825d |
| 5 | +**Branch:** master |
| 6 | + |
| 7 | +## OVERVIEW |
| 8 | + |
| 9 | +PHP SDK for SOLAPI messaging API (SMS, LMS, MMS, Kakao Alimtalk, Voice, Fax) targeting Korean telecom. Zero external dependencies, PHP 7.1+. |
| 10 | + |
| 11 | +## STRUCTURE |
| 12 | + |
| 13 | +``` |
| 14 | +solapi-php/ |
| 15 | +├── src/ |
| 16 | +│ ├── Services/ # Entry point (SolapiMessageService) |
| 17 | +│ ├── Libraries/ # HTTP client, auth, utilities |
| 18 | +│ ├── Models/ |
| 19 | +│ │ ├── Request/ # API request DTOs (7 files) |
| 20 | +│ │ ├── Response/ # API response DTOs (17 files) |
| 21 | +│ │ ├── Kakao/ # Kakao message options |
| 22 | +│ │ ├── Voice/ # Voice message options |
| 23 | +│ │ └── Fax/ # Fax message options |
| 24 | +│ └── Exceptions/ # Custom exceptions (4 files) |
| 25 | +├── composer.json # PSR-4: Nurigo\Solapi\ → src/ |
| 26 | +└── README.md |
| 27 | +``` |
| 28 | + |
| 29 | +## WHERE TO LOOK |
| 30 | + |
| 31 | +| Task | Location | Notes | |
| 32 | +|------|----------|-------| |
| 33 | +| Send messages | `Services/SolapiMessageService.php` | Main entry point, all public methods | |
| 34 | +| Build message | `Models/Message.php` | Fluent builder, extends BaseMessage | |
| 35 | +| HTTP requests | `Libraries/Fetcher.php` | Singleton, CURL-based | |
| 36 | +| Auth header | `Libraries/Authenticator.php` | HMAC-SHA256, static method | |
| 37 | +| Kakao options | `Models/Kakao/KakaoOption.php` | pfId, templateId, buttons, bms | |
| 38 | +| Voice options | `Models/Voice/VoiceOption.php` | voiceType, headerMessage, tailMessage | |
| 39 | +| Error handling | `Exceptions/` | BaseException, CurlException, MessageNotReceivedException | |
| 40 | +| Request params | `Models/Request/` | SendRequest, GetMessagesRequest, etc. | |
| 41 | +| Response parsing | `Models/Response/` | SendResponse, GroupMessageResponse, etc. | |
| 42 | + |
| 43 | +## CODE MAP |
| 44 | + |
| 45 | +**Entry Point:** |
| 46 | +```php |
| 47 | +$service = new SolapiMessageService($apiKey, $apiSecret); |
| 48 | +$response = $service->send($message); |
| 49 | +``` |
| 50 | + |
| 51 | +**Call Flow:** |
| 52 | +``` |
| 53 | +SolapiMessageService → Fetcher (singleton) → Authenticator (static) |
| 54 | + → CURL → api.solapi.com |
| 55 | + → Response DTOs |
| 56 | +``` |
| 57 | + |
| 58 | +**Key Classes:** |
| 59 | +| Class | Type | Role | |
| 60 | +|-------|------|------| |
| 61 | +| `SolapiMessageService` | Service | Primary API (send, uploadFile, getMessages, getGroups, getBalance) | |
| 62 | +| `Message` | Model | Message builder with fluent setters | |
| 63 | +| `Fetcher` | Library | HTTP client singleton, handles all API requests | |
| 64 | +| `Authenticator` | Library | Generates HMAC-SHA256 auth headers | |
| 65 | +| `NullEliminator` | Library | Removes null values before JSON serialization | |
| 66 | + |
| 67 | +## CONVENTIONS |
| 68 | + |
| 69 | +**Namespace:** `Nurigo\Solapi\*` (PSR-4 from `src/`) |
| 70 | + |
| 71 | +**Patterns:** |
| 72 | +- Fluent builder: `$msg->setTo("...")->setFrom("...")->setText("...")` |
| 73 | +- Singleton: `Fetcher::getInstance($key, $secret)` |
| 74 | +- Public properties with getters/setters on models |
| 75 | +- Korean PHPDoc comments (domain-specific) |
| 76 | + |
| 77 | +**Type Safety:** |
| 78 | +- Full type hints on method params/returns |
| 79 | +- PHPDoc `@var`, `@param`, `@return`, `@throws` annotations |
| 80 | + |
| 81 | +## ANTI-PATTERNS |
| 82 | + |
| 83 | +- **Avoid catch-all nulls:** Many get* methods return `null` on any exception — check response validity |
| 84 | +- **Singleton state:** Fetcher singleton retains credentials — don't mix different API keys in same process |
| 85 | +- **No interfaces:** Service/Fetcher have no contracts — mocking requires concrete class extension |
| 86 | +- **SSL verification disabled:** `CURLOPT_SSL_VERIFYPEER = false` in Fetcher |
| 87 | + |
| 88 | +## UNIQUE STYLES |
| 89 | + |
| 90 | +- **Korean comments:** PHPDoc descriptions in Korean (수신번호, 발신번호, 메시지 내용) |
| 91 | +- **Default country:** `"82"` (Korea) hardcoded in BaseMessage |
| 92 | +- **Timezone:** `Asia/Seoul` set in Authenticator |
| 93 | + |
| 94 | +## COMMANDS |
| 95 | + |
| 96 | +```bash |
| 97 | +# Install |
| 98 | +composer require solapi/sdk |
| 99 | + |
| 100 | +# No local tests — see solapi-php-examples repo |
| 101 | +``` |
| 102 | + |
| 103 | +## NOTES |
| 104 | + |
| 105 | +- **Examples:** External repo at `github.com/solapi/solapi-php-examples` |
| 106 | +- **API docs:** `developers.solapi.com` |
| 107 | +- **PHP requirement:** 7.1+ (ext-curl, ext-json required) |
| 108 | +- **TODO in README:** Missing documentation link (line 19) |
0 commit comments