blockshiftnetwork / composio-laravel
Laravel integration for Composio with PrismPHP and Laravel AI tool support
Package info
github.com/blockshiftnetwork/composio-laravel
pkg:composer/blockshiftnetwork/composio-laravel
Requires
- php: ^8.3
- blockshiftnetwork/composio-php: ^1.0
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- laravel/ai: ^0.4|^0.5|^0.6
- laravel/pint: ^1.29
- mockery/mockery: ^1.6
- orchestra/testbench: ^10.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.0
- prism-php/prism: ^0.99|^0.100
- rector/rector: ^2.3
Suggests
- laravel/ai: Only required when using the Laravel AI adapter to expose Composio tools as Laravel AI tools.
- prism-php/prism: Only required when using the PrismPHP adapter to expose Composio tools as Prism tools.
This package is auto-updated.
Last update: 2026-05-17 21:49:44 UTC
README
Laravel integration for Composio PHP v1 with first-class PrismPHP and Laravel AI tool support.
This package follows the current Composio TypeScript shape where possible:
Composio::create($userId, $config)creates a Tool Router session.Composio::use($sessionId)resumes a Tool Router session.Composio::tools($userId)exposes direct tools for PrismPHP or Laravel AI.- Connected accounts, auth configs, toolkits, triggers, MCP and files remain available through dedicated managers.
Legacy toolSet() and entityId APIs are intentionally not part of the v1 surface.
Installation
composer require blockshiftnetwork/composio-laravel
PrismPHP and Laravel AI are optional. Install only the adapter you use:
composer require prism-php/prism composer require laravel/ai
COMPOSIO_API_KEY=your-api-key COMPOSIO_BASE_URL=https://backend.composio.dev
Create A Tool Router Session
use BlockshiftNetwork\ComposioLaravel\Facades\Composio; $session = Composio::create('user_123', [ 'toolkits' => ['github', 'slack'], 'tools' => [ 'github' => ['GITHUB_CREATE_ISSUE', 'GITHUB_LIST_REPOS'], 'slack' => ['SLACK_SEND_MESSAGE'], ], 'manageConnections' => [ 'enable' => true, 'callbackUrl' => route('composio.callback'), 'inferScopesFromTools' => true, ], ]); $session->sessionId; $session->mcp;
The config builder accepts TypeScript-style keys and sends the v1 Tool Router payload (user_id, toolkits, tools, auth_configs, connected_accounts, manage_connections, workbench, preload, multi_account).
Use Session Tools With PrismPHP
$session = Composio::use('session_123'); $tools = $session->tools(); $result = $session->execute('GITHUB_CREATE_ISSUE', [ 'owner' => 'acme', 'repo' => 'api', 'title' => 'Bug from agent', ]);
Use Session Tools With Laravel AI
$session = Composio::use('session_123'); $tools = $session->laravelAiTools();
Both provider adapters execute through the session router, so tool calls respect the session configuration and connection management.
Authorize A Toolkit
$link = $session->authorize('github', route('composio.callback')); $link->getRedirectUrl(); $link->getConnectedAccountId();
Direct Tools
Use direct tools when you already know the user or connected account and do not need a Tool Router session.
$tools = Composio::tools('user_123') ->withConnectedAccount('ca_123') ->get('github', ['GITHUB_CREATE_ISSUE'], ['issues']); $result = Composio::tools('user_123') ->withConnectedAccount('ca_123') ->execute('GITHUB_CREATE_ISSUE', [ 'owner' => 'acme', 'repo' => 'api', 'title' => 'Bug from Laravel', ]);
Laravel AI direct tools:
$tools = Composio::tools('user_123') ->withConnectedAccount('ca_123') ->getLaravelAiTools('github');
Direct Tools Preset
For a TypeScript-compatible direct-tools session:
$session = Composio::create('user_123', [ 'sessionPreset' => 'direct_tools', 'toolkits' => ['github'], ]);
This sets:
search.enable = falseexecute.enable_multi_execute = false
Custom Tools
Custom PHP tools are exposed alongside direct Composio tools.
Composio::customTools()->register( slug: 'LOCAL_PING', description: 'Return pong', inputSchema: [], handler: fn (array $args) => json_encode(['pong' => true]), ); $tools = Composio::tools()->get();
Hooks
$tools = Composio::tools('user_123'); $tools->hooks()->beforeExecute('*', function (string $tool, array $arguments): array { $arguments['source'] = 'laravel'; return $arguments; });
Managers
Composio::connectedAccounts(); Composio::authConfigs(); Composio::toolkits(); Composio::triggers(); Composio::mcp(); Composio::files();
SDK Coverage Notes
The package uses blockshiftnetwork/composio-php v1 as the transport layer. Tool Router create, resume, toolkit listing, toolkit authorization and session execution are implemented directly. Methods that exist in the TypeScript SDK but are not generated by the PHP SDK yet, such as session search/update/proxy execution, throw an explicit ComposioException instead of silently doing the wrong thing.