zaengle/craft-phonehome 问题修复 & 功能扩展

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

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

zaengle/craft-phonehome

Composer 安装命令:

composer require zaengle/craft-phonehome

包简介

Phone Home plugin for Craft CMS

README 文档

README

Monitor the status of your #CraftCMS projects remotely

Phonehome a secure API endpoint that returns comprehensive information about a Craft CMS installation and the server environment it is installed in.

Requirements

This plugin requires Craft CMS 4.0.0+ or 5.0.0+, and PHP 8.1+.

Quickstart Installation

composer require zaengle/craft-phonehome
./craft plugin/install phonehome

then in config/phonehome.php add:

return [
     'token' => getenv('PHONEHOME_TOKEN'), // Your secure token from Zaengle Phone Home service
];

Documentation

See the full documentation online or in the docs/ directory of this repository.

API Schema

The plugin provides a JSON schema that defines the structure of the API response. The schema is located at src/schemas/PhonehomeApi.schema.json and follows semantic versioning.

You can retrieve the schema via the API endpoint:

GET /actions/phonehome/api/schema
X-Auth-Token: your-token-here

Important for contributors: When modifying the API response structure in Report::getInfo(), you must update the schema file accordingly and bump the schema version following semantic versioning rules. See CLAUDE.md for detailed schema maintenance guidelines.

Configuration

Additional Environment Variables

You can configure the plugin to include additional environment variables in the API response by setting additionalEnvKeys in your config/phonehome.php:

return [
    'token' => getenv('PHONEHOME_TOKEN'),
    'additionalEnvKeys' => [
        'MY_CUSTOM_ENV_VAR',
        'DEPLOYMENT_ID',
        'BUILD_NUMBER',
    ],
];

These values will be included in the meta section of the API response, making it easy to include deployment-specific information alongside the standard system metrics.

Extensibility

Custom Status Checks

You can register custom status checks to monitor application-specific health metrics. Status checks are registered via Craft's event system:

use yii\base\Event;
use zaengle\phonehome\services\Report;
use zaengle\phonehome\events\RegisterStatusChecksEvent;

Event::on(
    Report::class,
    Report::EVENT_REGISTER_STATUS_CHECKS,
    function(RegisterStatusChecksEvent $event) {
        $event->checks[] = MyCustomStatusCheck::class;
    }
);

Your status check class must implement StatusCheckInterface:

use zaengle\phonehome\statuschecks\StatusCheckInterface;
use zaengle\phonehome\models\StatusCheckResult;
use zaengle\phonehome\enums\StatusCheck;

class MyCustomStatusCheck implements StatusCheckInterface
{
    public static function getName(): string
    {
        return 'My Custom Check';
    }

    public static function getDescription(): string
    {
        return 'Monitors custom application metrics';
    }

    public static function check(): StatusCheckResult
    {
        return new StatusCheckResult([
            'name' => self::getName(),
            'status' => StatusCheck::OK,
            'description' => self::getDescription(),
            'meta' => [
                'custom_metric' => 'value',
            ],
        ]);
    }
}

Support

For support, visit the GitHub repository.

Development

See the development guide for details on how to contribute to this project.

统计信息

  • 总下载量: 5.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固