blockshiftnetwork / composio-php
Composio PHP SDK - API client library for Composio
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/blockshiftnetwork/composio-php
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
This package is auto-updated.
Last update: 2025-12-05 23:56:26 UTC
README
Auto-generated PHP client for the Composio API - Build AI applications faster with production-ready toolkits and integrations.
โ ๏ธ Important Notice: This is a generated client library based on Composio's OpenAPI specification. It is not maintained by Composio directly. For official SDKs, please check Composio's official repositories.
๐ What is Composio?
Composio is an open source platform that provides production-ready toolkits for building AI applications faster. With over 150+ integrations with popular services, Composio simplifies the process of connecting AI applications with external tools.
โจ Key Features
- ๐ 150+ Integrations: Salesforce, Gmail, Slack, GitHub, and many more
- ๐ Multiple Authentication Methods: OAuth, API Keys, custom flows
- โก Production-Ready: Designed for scalable applications
- ๐ Comprehensive Documentation: Detailed guides and API references
- ๐ ๏ธ Open Source: Open source with community contributions
๐ Requirements
- PHP 8.1 or higher
- Composer for dependency management
- PHP Extensions:
json,curl,mbstring
๐ฆ Installation
Using Composer
To use this generated client, you can install it from your local repository or create a package. Here's how to add it from a local path:
composer require blockshiftnetwork/composio-php
โ ๏ธ Generation Information
This client was generated using:
- OpenAPI Generator: v7.17.0
- API Version: v3.0.0
- Source: Composio's OpenAPI specification
- Language: PHP Client
- Build Date: 2025-12-05
To regenerate this client:
openapi-generator-cli generate -i openapi.json -g php -o composio2 --additional-properties invokerPackage=BlockshiftNetwork\\Composio
๐ Getting Started
Authentication Setup
Composio supports multiple authentication methods:
1. API Key (Recommended)
<?php require_once 'vendor/autoload.php'; use BlockshiftNetwork\Composio\Configuration; // Configure API key $config = Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', 'YOUR_API_KEY') ->setHost('https://backend.composio.dev');
2. Cookie Authentication
$config = Configuration::getDefaultConfiguration() ->setApiKey('authToken', 'YOUR_SESSION_TOKEN') ->setApiKeyPrefix('authToken', '');
3. Organization API Key
$config = Configuration::getDefaultConfiguration() ->setApiKey('x-org-api-key', 'YOUR_ORG_API_KEY');
Basic Example: List Toolkits
<?php require_once 'vendor/autoload.php'; use BlockshiftNetwork\Composio\Configuration; use BlockshiftNetwork\Composio\Api\ToolkitsApi; use GuzzleHttp\Client; // Configure authentication $config = Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', 'YOUR_API_KEY'); // Create API instance $api = new ToolkitsApi( new Client(), $config ); try { // List all available toolkits $result = $api->getToolkits(); echo "Available toolkits:\n"; foreach ($result->getItems() as $toolkit) { echo "- {$toolkit->getName()} ({$toolkit->getSlug()})\n"; echo " Description: {$toolkit->getMeta()->getDescription()}\n"; echo " Categories: " . implode(', ', $toolkit->getMeta()->getCategories()) . "\n\n"; } } catch (Exception $e) { echo "Error: " . $e->getMessage() . "\n"; }
Example: Execute a Tool
<?php use BlockshiftNetwork\Composio\Api\ToolsApi; use BlockshiftNetwork\Composio\Model\PostToolsExecuteByToolSlugRequest; // Create tools API instance $toolsApi = new ToolsApi( new Client(), $config ); // Execute a specific tool $request = new PostToolsExecuteByToolSlugRequest([ 'arguments' => [ 'repository' => 'username/repository', 'title' => 'Issue created from PHP SDK', 'body' => 'This issue was created automatically using Composio PHP SDK' ], 'connected_account_id' => 'CONNECTED_ACCOUNT_ID' ]); try { $result = $toolsApi->postToolsExecuteByToolSlug('github_create_issue', $request); echo "Issue created successfully:\n"; echo "URL: {$result->getData()->html_url}\n"; } catch (Exception $e) { echo "Error executing tool: " . $e->getMessage() . "\n"; }
Example: Manage Connected Accounts
<?php use BlockshiftNetwork\Composio\Api\ConnectedAccountsApi; $connectedAccountsApi = new ConnectedAccountsApi( new Client(), $config ); try { // List connected accounts $accounts = $connectedAccountsApi->getConnectedAccounts(); echo "Connected accounts:\n"; foreach ($accounts->getItems() as $account) { echo "- {$account->getToolkit()->getName()}: "; echo $account->getStatus() === 'ACTIVE' ? 'โ Active' : 'โ Inactive'; echo "\n"; } } catch (Exception $e) { echo "Error: " . $e->getMessage() . "\n"; }
๐ Available API Endpoints
The SDK provides access to all Composio API endpoints:
Authentication
GET /api/v3/auth/session/info- Get current session informationPOST /api/v3/auth/session/logout- End user session
Toolkits
GET /api/v3/toolkits- List available toolkitsGET /api/v3/toolkits/{slug}- Get specific toolkitGET /api/v3/toolkits/categories- List categoriesPOST /api/v3/toolkits/multi- Fetch multiple toolkits
Tools
GET /api/v3/tools- List available toolsGET /api/v3/tools/{tool_slug}- Get specific toolPOST /api/v3/tools/execute/{tool_slug}- Execute toolPOST /api/v3/tools/execute/{tool_slug}/input- Generate inputs from natural language
Connected Accounts
GET /api/v3/connected_accounts- List connected accountsPOST /api/v3/connected_accounts- Create new connected accountDELETE /api/v3/connected_accounts/{nanoid}- Delete connected accountPOST /api/v3/connected_accounts/{nanoid}/refresh- Refresh authentication
Tool Router (Experimental)
POST /api/v3/tool_router/session- Create tool router sessionPOST /api/v3/tool_router/session/{session_id}/execute- Execute in session
And many more endpoints for managing:
- Authentication Configurations (
/api/v3/auth_configs) - Projects and Organizations (
/api/v3/org/owner/project) - MCP Servers (
/api/v3/mcp) - Triggers (
/api/v3/triggers) - Files (
/api/v3/files)
๐ง Available Models
The SDK includes PHP models for all Composio entities:
Tool- Tool informationConnectedAccount- Connected accountsAuthConfig- Authentication configurationsToolkit- Toolkit informationError- Error handling- And many more...
๐ท๏ธ Popular Toolkit Categories
Composio organizes its toolkits into categories:
๐ผ Productivity
- Gmail - Email management
- Slack - Team communication
- Notion - Knowledge management
- Trello - Project management
๐ป Development
- GitHub - Version control
- GitLab - Code repositories
- Jira - Issue tracking
- Figma - Collaborative design
๐ Data & Analytics
- Salesforce - CRM
- HubSpot - Marketing and sales
- Google Sheets - Spreadsheets
- Airtable - Database
๐ E-commerce
- Shopify - Online store
- Stripe - Payments
- WooCommerce - WordPress e-commerce
๐ Supported Authentication Methods
Composio supports multiple authentication methods:
OAuth 2.0
- Standard authorization flow
- Automatic refresh tokens
- Custom scopes handling
API Keys
- Static API keys
- Custom headers
- Query parameters
Basic Authentication
- Username/Password
- HTTP Basic Auth
Custom Methods
- OAuth 1.0
- Bearer Tokens
- Custom headers
- Form-based authentication
๐งช Testing
To run the included tests:
# Install development dependencies composer install --dev # Run tests vendor/bin/phpunit
๐ Advanced Examples
Tool Router Session
<?php use BlockshiftNetwork\Composio\Api\ToolRouterApi; use BlockshiftNetwork\Composio\Model\PostToolRouterSessionRequest; $toolRouterApi = new ToolRouterApi(new Client(), $config); // Create a Tool Router session $sessionRequest = new PostToolRouterSessionRequest([ 'user_id' => 'user_123', 'config' => [ 'toolkits' => [ 'enabled' => ['github', 'slack', 'gmail'] ] ] ]); $session = $toolRouterApi->postToolRouterSession($sessionRequest); echo "Session created: {$session->getSessionId()}\n"; // Execute in session $executeRequest = [ 'tool_slug' => 'github_create_issue', 'arguments' => [ 'repository' => 'user/repo', 'title' => 'Issue from Tool Router' ] ]; $result = $toolRouterApi->postToolRouterSessionBySessionIdExecute( $session->getSessionId(), $executeRequest );
Error Handling
<?php use BlockshiftNetwork\Composio\ApiException; try { $result = $api->someMethod(); } catch (ApiException $e) { echo "API Error: {$e->getCode()} {$e->getMessage()}\n"; echo "Response body: {$e->getResponseBody()}\n"; echo "Response headers: " . json_encode($e->getResponseHeaders()) . "\n"; } catch (Exception $e) { echo "General error: " . $e->getMessage() . "\n"; }
๐ Framework Integrations
Laravel
// App/Http/Controllers/ComposioController.php namespace App\Http\Controllers; use BlockshiftNetwork\Composio\Configuration; use BlockshiftNetwork\Composio\Api\ToolkitsApi; class ComposioController extends Controller { protected $config; protected $api; public function __construct() { $this->config = Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', config('services.composio.api_key')); $this->api = new ToolkitsApi( new \GuzzleHttp\Client(), $this->config ); } public function index() { $toolkits = $this->api->getToolkits(); return view('composio.index', ['toolkits' => $toolkits->getItems()]); } }
Symfony
// src/Service/ComposioService.php namespace App\Service; use BlockshiftNetwork\Composio\Configuration; use BlockshiftNetwork\Composio\Api\ToolsApi; class ComposioService { private Configuration $config; private ToolsApi $toolsApi; public function __construct(string $apiKey) { $this->config = Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', $apiKey); $this->toolsApi = new ToolsApi( new \GuzzleHttp\Client(), $this->config ); } public function executeTool(string $toolSlug, array $arguments): array { $request = new \BlockshiftNetwork\Composio\Model\PostToolsExecuteByToolSlugRequest([ 'arguments' => $arguments ]); $result = $this->toolsApi->postToolsExecuteByToolSlug($toolSlug, $request); return $result->getData(); } }
๐ Best Practices
1. Configuration Management
// Environment variables $config = Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', $_ENV['COMPOSIO_API_KEY']) ->setHost($_ENV['COMPOSIO_API_HOST'] ?? 'https://backend.composio.dev');
2. Client Reuse
class ComposioClientFactory { private static ?Configuration $config = null; public static function getConfig(): Configuration { if (self::$config === null) { self::$config = Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', $_ENV['COMPOSIO_API_KEY']); } return self::$config; } public static function createToolkitsApi(): ToolkitsApi { return new ToolkitsApi( new \GuzzleHttp\Client([ 'timeout' => 30, 'connect_timeout' => 10 ]), self::getConfig() ); } }
3. Logging
use Monolog\Logger; use Monolog\Handler\StreamHandler; $logger = new Logger('composio'); $logger->pushHandler(new StreamHandler('logs/composio.log', Logger::DEBUG)); // Add middleware to Guzzle for logging $client = new \GuzzleHttp\Client([ 'handler' => \GuzzleHttp\HandlerStack::create(), ]); $handler = $client->getConfig('handler'); $handler->push(\GuzzleHttp\Middleware::log( $logger, new \GuzzleHttp\MessageFormatter('{method} {uri} - {code} - {req_body}') ));
โ ๏ธ Important Disclaimers
Library Status
- This is an auto-generated client library based on Composio's OpenAPI specification
- Not officially maintained by Composio
- Generated using OpenAPI Generator v7.17.0
- Based on Composio API v3.0.0
Limitations
- This client reflects the state of the OpenAPI specification at the time of generation
- Features may be outdated if the API has been updated
- For official support, contact Composio directly or use their official SDKs
When to Use This Client
- โ When you need a PHP client for Composio's API
- โ When there's no official PHP SDK available
- โ For rapid prototyping and development
- โ For production-critical applications without thorough testing
๐ค Contributing
Since this is an auto-generated client, contributions should focus on:
- API Specification Updates: Update the OpenAPI spec if Composio releases new versions
- Generation Improvements: Enhance the generation process or configuration
- Documentation: Improve this README and examples
- Bug Reports: Report issues with the generated client
Note: Do not manually edit the generated API files, as they will be overwritten during regeneration. Instead, update the OpenAPI specification and regenerate the client.
๐ License
This generated client follows the licensing terms of the OpenAPI Generator and the Composio API specification. Check the LICENSE file for specific licensing details.
๐ Support
Composio Official Support
- Documentation: https://composio.dev/docs
- API Reference: https://composio.dev/docs/api-reference
- Official Support: support@composio.dev
Generated Client Issues
Since this is an auto-generated client, issues should be reported to:
- This Repository: blockshiftnetwork/composio-php
- OpenAPI Generator: For generation-specific issues
- Composio: For API specification problems
Important: This generated client is not officially supported by Composio. For official SDK support, please use Composio's official repositories.
๐ Useful Links
- Composio Website
- Official Documentation
- GitHub Repository
- API Reference
- Authentication Guide
- Available Toolkits
๐ Changelog
Generated Client v1.0.0 (2025-12-05)
- โ Generated from Composio OpenAPI specification v3.0.0
- โ Full support for all API v3 endpoints
- โ PHP models for all entities
- โ Multiple authentication methods
- โ Tool Router support
- โ Complete documentation and examples
- โ Generated using OpenAPI Generator v7.17.0
๐ Useful Links
Official Composio Resources
- Composio Website
- Official Documentation
- API Reference
- Authentication Guide
- Available Toolkits
- Composio GitHub
Generation Tools
Build AI applications faster with Composio's production-ready toolkits ๐