This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the seven.io PHP SDK, an official API client for the seven.io SMS Gateway API. It's a PHP library that provides a clean, object-oriented interface for all seven.io services including SMS, Voice, RCS messaging, number lookup, and analytics.
# Run all tests with production API key
SEVEN_API_KEY=your_api_key php vendor/bin/phpunit tests
# Run all tests with sandbox API key (preferred for development)
SEVEN_API_KEY_SANDBOX=your_sandbox_key php vendor/bin/phpunit tests
# Run specific test file
php vendor/bin/phpunit tests/SmsTest.php
# Run tests with verbose output
php vendor/bin/phpunit tests --verbose# Generate API documentation (outputs to docs/ directory)
php vendor/bin/phpdoc# Install dependencies
composer install
# Install without dev dependencies
composer install --no-dev
# Update dependencies
composer update-
Client (
src/Client.php) - The main HTTP client that handles all API communication- Manages authentication via API keys and optional signing secrets
- Handles all HTTP methods (GET, POST, PATCH, DELETE)
- Implements request signing for webhook verification
- Manages error handling and exception throwing
-
Resources - Each API endpoint group has its own resource class
- All extend
src/Resource/Resource.phpabstract class - Located in
src/Resource/*/directories (Analytics, Sms, Voice, etc.) - Each resource handles specific API functionality (SMS sending, lookups, etc.)
- All extend
-
Parameter Objects - Type-safe parameter classes for API requests
- Follow naming pattern:
*Params.php(e.g.,SmsParams,VoiceParams) - Implement validation and provide fluent interfaces
- Follow naming pattern:
-
Response Objects - Structured response classes for API responses
- Located alongside their respective resources
- Provide type-safe access to response data
src/
├── Client.php # Main HTTP client
├── Exception/ # Custom exception classes
├── Library/ # Shared utilities and enums
└── Resource/ # API resource implementations
├── Resource.php # Abstract base class
├── Analytics/ # Analytics and reporting
├── Balance/ # Account balance
├── Contacts/ # Contact management
├── Groups/ # Contact groups
├── Hooks/ # Webhook management
├── Journal/ # Message history
├── Lookup/ # Number lookup/validation
├── Numbers/ # Phone number management
├── Pricing/ # Pricing information
├── Rcs/ # RCS messaging
├── Sms/ # SMS messaging (primary feature)
├── Status/ # Delivery status
├── Subaccounts/ # Subaccount management
├── ValidateForVoice/ # Voice validation
└── Voice/ # Voice calls
- Resource Pattern - Each API endpoint group is encapsulated in a Resource class
- Parameter Objects - Request parameters are wrapped in typed parameter objects
- Exception Hierarchy - Custom exceptions for different API error types
- Client Composition - Resources receive the Client instance for HTTP operations
SEVEN_API_KEY- Production API key for live testingSEVEN_API_KEY_SANDBOX- Sandbox API key for safe testing (preferred)SEVEN_SIGNING_SECRET- Optional webhook signing secretSEVEN_TEST_RECIPIENT- Custom recipient phone number for tests (default:491716992343)
- All tests extend
tests/AbstractTestCase.php - Uses
tests/Resources.phpas a resource factory for consistent test setup - Tests are organized by resource type (SmsTest.php, VoiceTest.php, etc.)
- Tests can switch between production and sandbox environments
- Create resource class extending
Resourcein appropriate namespace - Create parameter classes implementing
ParamsInterface - Create response/data classes for API responses
- Add validator classes if complex validation is needed
- Add corresponding test class extending
AbstractTestCase
The client automatically handles API error codes:
900- Invalid API Key901- Signing Hash Verification Failed902- Missing Access Rights903- Forbidden IP600- General API Error
The Client supports two authentication methods:
- API Key only (standard)
- API Key + Signing Secret (for webhook verification)
- PHP 8.2+
- Required extensions: curl, json, mbstring, ctype
- Development extensions: xdebug, soap, simplexml