Download the PHP package helgesverre/claude-code-sdk without Composer
On this page you can find all versions of the php package helgesverre/claude-code-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package claude-code-sdk
Claude Code SDK for PHP
PHP wrapper for Claude Code. Fun fact: This SDK was built by using Claude Code to port its own Python SDK to PHP. 🤖
Stream Claude's responses, track token usage, hook into events, and integrate AI coding assistance into your PHP apps.
Installation
Make sure Claude Code CLI is installed:
Quick Start
Basic Usage
With Options
Usage in Laravel
Configuration
Publish the configuration file:
Configure your settings in config/claude-code.php
or use environment variables:
Using the Facade
Dependency Injection
Configuration Options
Options
All configuration options available:
Message Types
The SDK provides strongly-typed message classes with proper DTOs:
SystemMessage
System events with typed data for initialization:
AssistantMessage
Contains content blocks with Claude's responses:
UserMessage
User input and tool feedback:
ResultMessage
Session completion with usage metrics:
MCP Server Configuration
Configure Model Context Protocol servers:
Interceptors
Note: This is NOT related to or the same as Claude Code Hooks
The SDK supports interceptors that allow you to tap into various events during the Claude Code lifecycle. This is useful for logging, monitoring, debugging, or building real-time UI updates.
Available Hook Points
onQueryStart
- Fired when a query beginsonRawMessage
- Fired when raw JSON is received from Claude Code CLIonMessageParsed
- Fired after a message is parsed into a typed objectonQueryComplete
- Fired when the query completes successfullyonError
- Fired when an error occurs
Basic Usage
Example Interceptors
File Logger
Metrics Collector
Webhook Dispatcher
Custom Interceptor
Laravel Integration
Error Handling
The SDK provides specific exception types for different failure scenarios:
License
This SDK is open-source software licensed under the MIT license.