bapp/api-client
Composer 安装命令:
composer require bapp/api-client
包简介
BAPP Auto API Client for PHP
README 文档
README
Official PHP client for the BAPP Auto API. Provides a simple, consistent interface for authentication, entity CRUD, and task execution.
Getting Started
1. Install
composer require bapp/api-client
2. Create a client
<?php use Bapp\BappApiClient; $client = new BappApiClient(['token' => 'your-api-key']);
3. Make your first request
// List with filters $countries = $client->list('core.country', ['page' => 1, 'search' => 'Romania']); // Get by ID $country = $client->get('core.country', '42'); // Create $new = $client->create('core.country', ['name' => 'Romania', 'code' => 'RO']); // Patch (partial update) $client->patch('core.country', '42', ['code' => 'RO']); // Delete $client->delete('core.country', '42');
Authentication
The client supports Token (API key) and Bearer (JWT / OAuth) authentication.
Token auth already includes a tenant binding, so you don't need to specify tenant separately.
// Static API token (tenant is included in the token) $client = new BappApiClient(['token' => 'your-api-key']); // Bearer (JWT / OAuth) $client = new BappApiClient(['bearer' => 'eyJhbG...', 'tenant' => '1']);
Configuration
tenant and app can be changed at any time after construction:
$client->tenant = '2'; $client->app = 'wms';
API Reference
Client options
| Option | Description | Default |
|---|---|---|
token |
Static API token (Token <value>) — includes tenant |
— |
bearer |
Bearer / JWT token | — |
host |
API base URL | https://panel.bapp.ro/api |
tenant |
Tenant ID (x-tenant-id header) |
None |
app |
App slug (x-app-slug header) |
"account" |
timeout |
HTTP request timeout (seconds) | 30 |
max_retries |
Max retries on transient errors (5xx, 429, connection) | 3 |
Methods
| Method | Description |
|---|---|
me() |
Get current user profile |
get_app(app_slug) |
Get app configuration by slug |
list(content_type, **filters) |
List entities (paginated) |
get(content_type, id) |
Get a single entity |
create(content_type, data) |
Create an entity |
update(content_type, id, data) |
Full update (PUT) |
patch(content_type, id, data) |
Partial update (PATCH) |
delete(content_type, id) |
Delete an entity |
list_introspect(content_type) |
Get list view metadata |
detail_introspect(content_type) |
Get detail view metadata |
get_document_views(record) |
Extract available views from a record |
get_document_url(record, output?, label?, variation?) |
Build a render/download URL |
get_document_content(record, output?, label?, variation?) |
Fetch document bytes (PDF, HTML, JPG) |
download_document(record, dest, output?, label?, variation?) |
Stream document to file (memory-efficient) |
list_tasks() |
List available task codes |
detail_task(code) |
Get task configuration |
run_task(code, payload?) |
Execute a task |
run_task_async(code, payload?) |
Run a long-running task and poll until done |
Paginated responses
list() returns the results directly as a list/array. Pagination metadata is
available as extra attributes:
count— total number of items across all pagesnext— URL of the next page (ornull)previous— URL of the previous page (ornull)
File Uploads
When data contains file objects, the client automatically switches from JSON to
multipart/form-data. Mix regular fields and files in the same call:
// CURLFile or SplFileInfo values trigger multipart/form-data automatically $client->create('myapp.document', [ 'name' => 'Report', 'file' => new \CURLFile('/path/to/report.pdf'), ]); // Or use SplFileInfo $client->create('myapp.document', [ 'name' => 'Report', 'file' => new \SplFileInfo('/path/to/report.pdf'), ]);
Document Views
Records may include public_view and/or view_token fields with JWT tokens
for rendering documents (invoices, orders, reports, etc.) as HTML, PDF, or images.
The SDK normalises both formats and builds the correct URL automatically:
$order = $client->get('company_order.order', '42'); // Get a PDF download URL (auto-detects public_view vs view_token) $url = $client->getDocumentUrl($order, 'pdf'); // Pick a specific view by label $url = $client->getDocumentUrl($order, 'html', 'Comanda interna'); // Use a variation $url = $client->getDocumentUrl($order, 'pdf', null, 'v4'); // Fetch the actual content as bytes $pdfBytes = $client->getDocumentContent($order, 'pdf'); file_put_contents('order.pdf', $pdfBytes); // Enumerate all available views $views = $client->getDocumentViews($order); foreach ($views as $v) { echo $v['label'] . ' ' . $v['type'] . PHP_EOL; }
get_document_views() returns a list of normalised view entries with label,
token, type ("public_view" or "view_token"), variations, and
default_variation. Use it to enumerate available views (e.g. for a dropdown).
Tasks
Tasks are server-side actions identified by a dotted code (e.g. myapp.export_report).
$tasks = $client->listTasks(); $cfg = $client->detailTask('myapp.export_report'); // Run without payload (GET) $result = $client->runTask('myapp.export_report'); // Run with payload (POST) $result = $client->runTask('myapp.export_report', ['format' => 'csv']);
Long-running tasks
Some tasks run asynchronously on the server. When triggered, they return an id
that can be polled via bapp_framework.taskdata. Use run_task_async() to
handle this automatically — it polls until finished is true and returns the
final task data (which includes a file URL when the task produces a download).
License
MIT
bapp/api-client 适用场景与选型建议
bapp/api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「client」 「bapp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bapp/api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bapp/api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bapp/api-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
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%).
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-05