apitoolkit/apitoolkit-slim
Composer 安装命令:
composer require apitoolkit/apitoolkit-slim
包简介
APIToolkit SDK for php slim framework
README 文档
README
Slim SDK
APItoolkit is an end-to-end API and web services management toolkit for engineers and customer support teams. To integrate your Slim (PHP) application with APItoolkit, you need to use this SDK to monitor incoming traffic, aggregate the requests, and then deliver them to the APItoolkit's servers.
Table of Contents
Installation
Kindly run the command below to install the apitoolkit-slim sdk and otel packages:
composer require \
open-telemetry/sdk \
open-telemetry/exporter-otlp \
open-telemetry/opentelemetry-auto-slim \
open-telemetry/opentelemetry-auto-psr18 \
apitoolkit/apitoolkit-slim
Setup Opentelemetry
Installing opentelemetry extension
After installing the necessary packages, you'll need to install the opentelemetry extention and add it to your php.ini file
pecl install opentelemetry
Then add it to your php.ini file like so.
[opentelemetry] extension=opentelemetry.so
Export the following environment variables to configure the opentelemetry extension.
export OTEL_PHP_AUTOLOAD_ENABLED=true export OTEL_SERVICE_NAME=your-service-name export OTEL_TRACES_EXPORTER=otlp export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf export OTEL_EXPORTER_OTLP_ENDPOINT=http://otelcol.apitoolkit.io:4318 export OTEL_RESOURCE_ATTRIBUTES="at-project-key={ENTER_YOUR_API_KEY_HERE}" export OTEL_PROPAGATORS=baggage,tracecontext
Setup APItoolkit Middleware
Next, create a new instance of the APIToolkitMiddleware class and register the middleware with the Slim Framework in the app/middleware.php file. This creates a customs spans which captures and sends http request info such as headers, requests and repsonse bodies, matched route etc. for each request
use Slim\Factory\AppFactory; use APIToolkit\APIToolkitMiddleware; require __DIR__ . '/vendor/autoload.php'; $app = AppFactory::create(); $apitoolkitMiddleware = new APIToolkitMiddleware(['captureRequestBody' => true]); $app->add($apitoolkitMiddleware); $app->get('/', function ($request, $response) { $response->getBody()->write('Hello, World!'); return $response; }); $app->run();
Note
The {ENTER_YOUR_API_KEY_HERE} demo string should be replaced with the API key generated from the APItoolkit dashboard.
Important
To learn more configuration options (redacting fields, error reporting, outgoing requests, etc.), please read this SDK documentation.
Contributing and Help
To contribute to the development of this SDK or request help from the community and our team, kindly do any of the following:
- Read our Contributors Guide.
- Join our community Discord Server.
- Create a new issue in this repository.
License
This repository is published under the MIT license.
apitoolkit/apitoolkit-slim 适用场景与选型建议
apitoolkit/apitoolkit-slim 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「microframework」 「rest」 「apis」 「apitoolkit」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 apitoolkit/apitoolkit-slim 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 apitoolkit/apitoolkit-slim 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 apitoolkit/apitoolkit-slim 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
A lightweight, secure-by-default PHP microframework built on Slim – providing Laravel-like features (ORM, authentication, migrations, caching) without the bloat. Perfect for building REST APIs and small-to-medium PHP applications.
An API Development Kit (ADK) to consistently build and manage APIs
An HTTP Kipchak driver (dependency) for the Kipchak API Development Kit (ADK)
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-11