fyennyi/mofh-api-client
Composer 安装命令:
composer require fyennyi/mofh-api-client
包简介
PSR-compliant MyOwnFreeHost API Client.
README 文档
README
A PSR-compliant client for interacting with the MyOwnFreeHost (MOFH) API. This library provides a structured, type-safe way to manage hosting accounts, domains, and support tickets.
Features
- PSR-18 Compliant: Use any compatible HTTP client (Guzzle, Symfony, etc.).
- PSR-17 Compliant: Decoupled request factories.
- PSR-3 Logging: Built-in support for logging request/response cycles.
- Domain Driven Design: Separated repositories for Accounts, Domains, Support, and System.
- Strictly Typed: Utilizes DTOs (Data Transfer Objects) for all API interactions.
Installation
You can install the package via Composer:
composer require fyennyi/mofh-api-client
Basic Usage
Initialization
use Fyennyi\MofhApi\Client; use Fyennyi\MofhApi\Connection; use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\Psr7\HttpFactory; // Initialize dependencies $httpClient = new GuzzleClient(['verify' => false]); // MOFH certificates are often expired $requestFactory = new HttpFactory(); $connection = new Connection('your_api_username', 'your_api_password'); // Create the client $mofh = new Client($connection, $httpClient, $requestFactory);
Managing Accounts
use Fyennyi\MofhApi\Dto\Account\CreateAccountRequest; use Fyennyi\MofhApi\Dto\Support\TicketReply; // Create a new hosting account try { $request = new CreateAccountRequest( username: 'exampleuser', password: 'secure_password', contactEmail: 'user@example.com', domain: 'user.yourdomain.com', plan: 'MyPlan' ); $response = $mofh->account->create($request); echo "Account created: " . $response->vPanelUsername; } catch (\Exception $e) { echo "Error: " . $e->getMessage(); } // Support System: Create and Reply to tickets $ticketId = $mofh->support->createTicket('hname_1234', 'Issue', 'Text', 'domain.com'); $mofh->support->reply(new TicketReply($ticketId, 'My response message')); // Suspend an account $mofh->account->suspend('hname_12345678', 'Policy violation.');
Domain & System Information
// Check if a domain is available $isAvailable = $mofh->domain->checkAvailability('test.example.com'); // Get account info by domain name $userData = $mofh->domain->getUserByDomain('test.example.com'); // Get CNAME validation token (MD5) $token = $mofh->system->getCnameToken('my-new-site.com'); // List available hosting packages $packages = $mofh->system->getPackages(); foreach ($packages as $package) { echo "Plan: {$package->name} | Quota: {$package->diskQuota}MB\n"; }
Error Handling
The library throws Fyennyi\MofhApi\Exception\MofhException for API-level errors or transport issues.
try { $mofh->account->remove('hname_12345678'); } catch (\Fyennyi\MofhApi\Exception\MofhException $e) { // Handle specific API error }
Requirements
- PHP 8.1 or higher.
ext-jsonandext-simplexmlextensions.
Contributing
Contributions are welcome and appreciated! Here's how you can contribute:
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the existing coding style.
License
This library is licensed under the CSSM Unlimited License v2.0 (CSSM-ULv2). See the LICENSE file for details.
fyennyi/mofh-api-client 适用场景与选型建议
fyennyi/mofh-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fyennyi/mofh-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fyennyi/mofh-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LicenseRef-CSSM-Unlimited-2.0
- 更新时间: 2026-02-09