pxgamer/minimin

服务器管理的模块化 PHP 接口。

v1.0.4 2017-12-07 17:16 UTC

This package is auto-updated.

Last update: 2024-09-11 14:05:57 UTC


README

Latest Version on Packagist Software License Build Status Style CI Code Coverage Total Downloads

服务器管理的模块化 PHP 接口。

结构

public/
src/
tests/
vendor/

安装

通过 Composer

$ composer create-project pxgamer/minimin

用法

基本插件格式

插件可访问的类

  • 更智能的(这需要使用 addTemplateDir() 添加自定义模板目录)
  • 系统*(nezamy/route 类)
  • 它们导入/需要的任何类

包应遵循以下目录结构

/
    src/
        /Templates
            /{PluginName}
        App.php
        Plugin.php
    composer.json

为参考,查看 Github 上的 minimin-package-example 插件。

App.php

<?php

namespace {vendor}\{plugin};

use pxgamer\Minimin\Smarter;

class App
{
    // When initialised by the Minimin class, it will pass the $route to the plugin App constructor
    public function __construct($route)
    {
        // ... Run plugin commands
        $Smarter = Smarter::get();
        $Smarter->addTemplateDir(__DIR__ . '/Templates/');
    }
}

Plugin.php

<?php

namespace {vendor}\{plugin};

class Plugin
{
    public static function info()
    {
        /** This function MUST return the following values:
         *  - app_namespace
         *  - name
         *  - link
         *  - description
         */
        
        $object = (object)[
            'app_namespace' => '\\{vendor}\\{plugin}', // The namespace of the plugin
            'name' => 'Cron Tasks', // The name of the plugin, may contain spaces
            'link' => 'cron-tasks', // The link that will be used (e.g. `cron-tasks` will be `/cron-tasks`)
            'description' => 'A cron task manager for servers.' // The description of the plugin
        ];
        
        return $object;
    }
}

示例 data/plugins.json 格式

[
  {
    "app_namespace": "\\pxgamer\\CronTasks",
    "name": "Cron Tasks",
    "link": "cron-tasks",
    "description": "A cron task manager for servers."
  }
]

贡献

请参阅 CONTRIBUTINGCODE_OF_CONDUCT 以获取详细信息。

安全性

如果您发现任何安全问题,请通过电子邮件 owzie123@gmail.com 而不是使用问题跟踪器。

鸣谢

许可证

MIT 许可证(MIT)。请参阅 许可证文件 以获取更多信息。