The Claude PHP SDK by Dale Hurley provides 1-for-1 functionality with the official Python SDK, supporting PHP v8.1+. Along with a PHP SDK, the author has a Laravel integration, Claude-PHP-SDK-Laravel, which includes a service Facade:
use ClaudePhp\Laravel\Facades\Claude; response()->stream(function () use ($request) { $stream = Claude::messages()->stream([ 'model' => 'claude-sonnet-4-5-20250929', 'max_tokens' => 2048, 'messages' => [ ['role' => 'user', 'content' => $request->input('message')] ] ]); foreach ($stream as $event) { if (($event['type'] ?? '') === 'content_block_delta') { echo "data: " . json_encode(['text' => $event['delta']['text'] ?? '']) . "\n\n"; ob_flush(); flush(); } }}, 200, [ 'Content-Type' => 'text/event-stream', 'Cache-Control' => 'no-cache', 'X-Accel-Buffering' => 'no',]);
Main Features
- Full API Parity: Comprehensive implementation of Messages, Files, Batches, and Models APIs
- Complete Example Coverage: 80+ comprehensive examples covering all Claude documentation pages (11,000+ lines)
- PSR Compliance: Follows PSR-12 coding standards and PSR-11 dependency injection patterns
- Framework Agnostic: Works seamlessly with Laravel, Symfony, Slim, and other PHP frameworks
- Latest Models: Support for Claude Sonnet 4.5, Haiku 4.5, and Opus 4.5
- Advanced Features: Tool use, vision, streaming, extended thinking, embeddings, batch processing, and more
- Async Ready: Built for modern async patterns with Amphp support
- Comprehensive Error Handling: Detailed exception hierarchy matching the Python SDK
- Production Ready: All examples tested, documented, and verified with live API calls
👨💻 You can get started with this package on GitHub: claude-php/Claude-PHP-SDK.
📕 There are over 80+ examples in the repo's examples directory and a tutorials folders.