承接 bit-part/mt-data-api-php-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bit-part/mt-data-api-php-client

Composer 安装命令:

composer require bit-part/mt-data-api-php-client

包简介

Thin, safe Movable Type Data API v7 client for PHP.

README 文档

README

PHPStan License: MIT

Movable Type Data API v7のための、薄く、安全で、PSR準拠のPHPクライアントライブラリです。

特徴

  • PSR準拠: PSR-7 (HTTP Message)、PSR-17 (HTTP Factories)、PSR-18 (HTTP Client)、PSR-3 (Logger)を実装
  • 型安全: PHP 8.2+の厳格な型付けとPHPStan level max準拠
  • 柔軟性: 任意のPSR-18互換HTTPクライアント使用可能(Guzzleがデフォルト)
  • 開発者フレンドリー: 流暢なクエリビルダー、自動ページネーション、包括的なエラーハンドリング
  • 完全テスト: Pestフレームワークによる完全なテストカバレッジ
  • 自動生成: OpenAPI仕様からResourceクラスを自動生成

要件

  • PHP 8.2 以上
  • Composer

インストール

composer require bit-part/mt-data-api-php-client

環境設定(推奨)

認証情報を安全に管理するため、.env ファイルの使用を推奨します。

# .env サポートパッケージをインストール
composer require vlucas/phpdotenv

# .env.example をコピー
cp vendor/bit-part/mt-data-api-php-client/.env.example .env

# .env を編集して実際の値を設定

詳細は USAGE.md - 環境設定 を参照してください。

クイックスタート

<?php

use Bitpart\MtDataApi\Client;
use GuzzleHttp\Client as GuzzleClient;
use Nyholm\Psr7\Factory\Psr17Factory;

// Initialize the client
$httpClient = new GuzzleClient();
$factory = new Psr17Factory();

$client = new Client(
    baseUrl: 'https://example.com/mt-data-api.cgi/v7',
    httpClient: $httpClient,
    requestFactory: $factory,
    streamFactory: $factory
);

// Authenticate (clientId is strongly recommended)
$authenticator = $client->getAuthenticator();
$authResult = $authenticator->login(
    username: 'username',
    password: 'password',
    remember: true,
    clientId: 'my-application'
);
$client = $authResult->client;

// Make API calls
$sites = $client->raw('GET', 'sites');

Resource Helpers

use Bitpart\MtDataApi\Query\Query;

// Entries scoped to site 1
$entries = $client->entries(1);

// List entries (returns the `items` array)
$items = $entries->list(Query::make()->limit(20));

// Create a new entry
$created = $entries->create([
    'title' => 'Hello World',
    'status' => 'Publish',
]);

// Upload an asset
$asset = $client->assets(1)->upload('/path/to/image.jpg', ['label' => 'Cover']);

// Publish a template
$client->publish(1)->template(123);

// Preview a page
$preview = $client->preview(1)->page([
    'page' => ['title' => 'Draft title'],
]);

Authentication Workflow

use Bitpart\MtDataApi\Auth\Authenticator;

$authenticator = new Authenticator($client);

// Login with username/password
// Note: clientId is strongly recommended for MT Data API v7
$login = $authenticator->login(
    username: 'username',
    password: 'password',
    clientId: 'my-application'  // Identifies your application
);
$client = $login->client; // holds access token & session id

// Refresh token later using stored session id
$refreshed = (new Authenticator($client))->refresh();
$client = $refreshed->client;

// Logout to invalidate session & token
$client = (new Authenticator($client))->logout();

Development

The quick summary is below; see docs/TESTING.md for expanded guidance.

Setup

composer install

Code Quality

# Run static analysis
composer lint

# Format code
composer format

# Run tests
composer test

# Run all CI checks
composer test:ci

Project Structure

src/
  Client.php              # Main client class
  Auth/                   # Authentication
  Exceptions/             # Custom exceptions
  Http/                   # PSR-18 adapters
  Query/                  # Query builder
  Pagination/             # Pagination helpers
  Resources/              # API resource endpoints

ドキュメント

📚 利用者向け

🔧 開発者向け

License

MIT License - see LICENSE file for details.

Contributing

This project follows PSR-12 coding standards and requires PHPStan level max compliance.

Support

bit-part/mt-data-api-php-client 适用场景与选型建议

bit-part/mt-data-api-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cms」 「rest client」 「psr-3」 「api client」 「data api」 「psr-7」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 bit-part/mt-data-api-php-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bit-part/mt-data-api-php-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 bit-part/mt-data-api-php-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-05