drnio/directus-v8-manager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

drnio/directus-v8-manager

Composer 安装命令:

composer require drnio/directus-v8-manager

包简介

A PHP client for interacting with the **Directus v8 API**. This package provides easy-to-use methods for performing **CRUD operations**, managing Directus collections, and handling **authentication**, making it simple to integrate Directus into your PHP applications.

README 文档

README

A lightweight PHP client for interacting with the Directus v8 API. This package provides convenient helpers for authentication, token management, and CRUD operations.

Quick Links

Features

  • User authentication (login, logout, token refresh)
  • CRUD operations for collections and items
  • Pagination support for large datasets
  • Error handling via exceptions and structured responses
  • Token management (access and refresh tokens)

Requirements

  • PHP 7.4+
  • Composer
  • Running Directus v8 instance

Installation

composer require drnio/directus-v8-manager

Environment Setup

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

$baseUrl = getenv('DIRECTUS_BASE_URL');
$email = getenv('DIRECTUS_EMAIL');
$password = getenv('DIRECTUS_PASSWORD');

Classes Documentation

1. DirectusAuth

Handles authentication and token management.

Methods:

  • __construct($baseUrl, $email, $password) — Initialize with API base URL and user credentials.
  • authenticate() — Authenticate the user and return access token.
  • refreshToken() — Refresh access token using refresh token.
  • logout() — Invalidate current token and logout.

Usage Example:

use Drnio\DirectusV8Manager\DirectusAuth;

$auth = new DirectusAuth($baseUrl, $email, $password);
$token = $auth->authenticate();
$newToken = $auth->refreshToken();
$auth->logout();

// Create new user
$newUser = $directus->createUser([
  'email' => 'newuser@example.com',
  'password' => 'pass1234',
  'role' => 'viewer'
]);

// Get a user
$user = $directus->getUserById(12);

// Get a user by email
$user = $directus->getUserByEmail('email@domail.com');

// Update user
$updated = $directus->updateUser(12, ['first_name' => 'John', 'last_name' => 'Doe']);

// Delete user
$directus->deleteUser(12);

2. DirectusClient

Provides CRUD operations for Directus collections/items.

Methods:

  • __construct($baseUrl, $accessToken) — Initialize client with base URL and token.
  • items($collectionName) — Returns a helper object for collection operations.
    • get($params = []) — Retrieve items with optional parameters.
    • create($data) — Create a new item in the collection.
    • update($id, $data) — Update an item by ID.
    • delete($id) — Delete an item by ID.
    • paginate($params = []) — Iterate over items page by page.

Usage Example:

use Drnio\DirectusV8Manager\DirectusClient;

$client = new DirectusClient($baseUrl, $token);

// Retrieve items
$items = $client->items('articles')->get(['limit' => 50]);

// Create item
$newItem = $client->items('articles')->create(['title' => 'Hello', 'body' => 'World']);

// Update item
$updatedItem = $client->items('articles')->update($itemId, ['title' => 'Updated']);

// Delete item
$client->items('articles')->delete($itemId);

// Pagination example
foreach ($client->items('articles')->paginate(['limit' => 100]) as $page) {
    foreach ($page['data'] as $row) {
        // Process each row
    }
}

Error Handling

Wrap API calls with try/catch:

try {
    $items = $client->items('articles')->get();
} catch (\Exception $e) {
    error_log($e->getMessage());
}

Contributing

  1. Fork repository
  2. Create feature branch
  3. Add tests and documentation
  4. Open Pull Request

Follow PSR-12 / PSR-4 coding standards.

License

MIT © Dr-Nio

drnio/directus-v8-manager 适用场景与选型建议

drnio/directus-v8-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 drnio/directus-v8-manager 我们能提供哪些服务?
定制开发 / 二次开发

基于 drnio/directus-v8-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-01