blockshiftnetwork/composio-php
Composer 安装命令:
composer require blockshiftnetwork/composio-php
包简介
Composio PHP SDK - API client library for Composio API v3.1
关键字:
README 文档
README
Auto-generated PHP client for the Composio API v3.1.
This package is generated from Composio's OpenAPI document and is not maintained by Composio directly. The public PHP namespace remains BlockshiftNetwork\Composio.
Requirements
- PHP 8.1 or higher
- Composer
- PHP extensions:
curl,json,mbstring
Installation
composer require blockshiftnetwork/composio-php
Authentication
<?php require_once __DIR__ . '/vendor/autoload.php'; use BlockshiftNetwork\Composio\Configuration; $config = Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', 'YOUR_API_KEY') ->setHost('https://backend.composio.dev');
Supported auth keys generated from the OpenAPI document:
x-api-keyx-user-api-keyx-org-api-keyauthTokencookie
Example
<?php require_once __DIR__ . '/vendor/autoload.php'; use BlockshiftNetwork\Composio\Api\ToolkitsApi; use BlockshiftNetwork\Composio\Configuration; use GuzzleHttp\Client; $config = Configuration::getDefaultConfiguration() ->setApiKey('x-api-key', 'YOUR_API_KEY'); $toolkits = new ToolkitsApi(new Client(), $config); $response = $toolkits->getV31Toolkits(); print_r($response);
Generated endpoint documentation is available under docs/Api, and generated model documentation is available under docs/Model.
Regeneration
The SDK is generated from:
https://backend.composio.dev/api/v3.1/openapi.json
The upstream OpenAPI document currently needs a small normalization pass:
- three
session_idpath parameters are not markedrequired: true - four
toolkit_versionsquery parameters needdeepObjectmetadata so PHP can preserve bracket notation such astoolkit_versions[gmail]=20250930_00
The normalizer preserves the API shape and only fixes invalid or underspecified OpenAPI metadata before code generation.
After generation:
scripts/fix-generated-query-serialization.phppatches the generated query serializer so map-likearray<string,...>query values keep their keys fordeepObjectparameters.scripts/fix-generated-map-serialization.phppatches JSON request serialization so empty map-like fields such as toolargumentsare sent as{}instead of[].scripts/fix-generated-connected-account-state.phppatches the generated connected-account state wrapper so realOAUTH2state responses deserialize correctly instead of being constrained to the last inlineoneOfbranch.scripts/fix-generated-duplicates.phpremoves duplicate PHP methods that OpenAPI Generator can emit for inline schemas whose JSON fields converge to the same accessor name. Without this post-process, a few generated models/tests are not loadable by PHP.
Regenerate with:
composer run openapi:regenerate
For future OpenAPI/API-version updates, follow the maintained checklist in docs/MAINTAINING.md. It covers updating the upstream spec URL/version, reviewing normalizations and post-generation patches, running official docs verification, live read-only checks, live end-to-end tool execution, tests, lint, and release-level decisions.
Equivalent manual commands:
php scripts/update-openapi-spec.php openapi-generator-cli validate -i openapi/composio-v3.1.openapi.json php scripts/clean-generated.php openapi-generator-cli generate -c openapi-generator-config.json --minimal-update php scripts/fix-generated-query-serialization.php php scripts/fix-generated-map-serialization.php php scripts/fix-generated-connected-account-state.php php scripts/fix-generated-duplicates.php
Verification
Use the official Composio reference check to compare the generated local OpenAPI snapshot against the public documentation:
composer run docs:verify
This downloads the current pages linked from https://docs.composio.dev/reference, extracts every documented /api/v3.1 endpoint, and verifies that each one exists in openapi/composio-v3.1.openapi.json with a generated PHP API method.
Run the generated tests and maintained smoke tests with:
composer test
The maintained smoke tests use Guzzle's mock handler to verify representative generated requests for authentication headers, query serialization, path parameter replacement, JSON request bodies, and response deserialization.
They also cover PHP's empty-map edge case so request fields like arguments => [] serialize as JSON objects when the OpenAPI type is array<string,mixed>.
If .env contains COMPOSIO_API_KEY, run read-only live verification with:
composer run live:verify
This calls representative live GET endpoints and reports only HTTP status plus generic counts. It does not print credentials or response bodies.
For a release-gate end-to-end check against the live API, run:
composer run live:e2e
This uses the generated SDK to discover the no-auth read-only HACKERNEWS_GET_TOP_STORIES tool, fetch its schema, execute it through ToolsApi, create a Tool Router session, and execute the same tool through the session. It does not require connecting a third-party account, and it reports only statuses, model names, generic data types, and whether IDs are present.
Generation settings:
- OpenAPI Generator CLI:
7.22.0viaopenapitools.json - Generator:
php - Composer package:
blockshiftnetwork/composio-php - Invoker namespace:
BlockshiftNetwork\Composio - Variable naming convention:
original - API host:
https://backend.composio.dev
Notes
- This release targets
/api/v3.1paths. - The v3.1 OpenAPI surface generates 40 API classes and 449 model classes.
- Existing v3 generated model and method names may change because OpenAPI operation IDs now include
V31.
blockshiftnetwork/composio-php 适用场景与选型建议
blockshiftnetwork/composio-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 90 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「rest」 「api」 「sdk」 「openapi」 「openapitools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 blockshiftnetwork/composio-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 blockshiftnetwork/composio-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 blockshiftnetwork/composio-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
BlockCypher's PHP SDK for REST API
Helper classes for creating cookie headers
统计信息
- 总下载量: 90
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-05