coenjacobs/conductor 问题修复 & 功能扩展

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

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

coenjacobs/conductor

Composer 安装命令:

composer require coenjacobs/conductor

包简介

Enforces your WordPress plugin requirements

README 文档

README

Conductor allows you to check the requirements for your WordPress plugin, before you start your plugin. Say you require a certain PHP version, or a minimum version of another plugin to be active. Conductor has you covered with an easy to use set of checks.

This package requires PHP 5.3 or higher in order to run the tool.

Warning: This package is very experimental and breaking changes are very likely until version 1.0.0 is tagged. Use with caution, always wear a helmet when using this in production environments.

Installation

This package can be best installed inside your plugin, by using Composer:

composer require coenjacobs/conductor

Best results are achieved when installing this library in combination with the Mozart package, so Conductor will be installed in your own namespace to prevent conflicts.

Checks

Conductor is based on simple Check classes that check a single conditional. This can be to check for the PHP version on the current server, or another plugin being active (and of a minimum version number itself).

These Check classes are registered with a central Handler and provided with the right details to check for through a single array of settings. A single call to the check() method on the Handler will then run through all those checks and will let you know whether those requirements are being satisfied. A simple example of how this works in code:

$handler = new CoenJacobs\Conductor\Handler();
$handler->setup([
    [
        'type' => 'php',
        'version' => '5.6.0',
    ],
    [
        'type' => 'plugin',
        'name' => 'WooCommerce',
        'slug' => 'woocommerce/woocommerce.php',
        'version' => '3.1.0',
    ],
]);

if ( $handler->check() === false ) {
    // if you end up here, something failed...
}

The provided arguments speak for itself, but to summarize the checks this will perform:

  • The minimum PHP version has to be 5.6.0.
  • The WooCommerce plugin has to be active, with a minimum version of 3.1.0.

If $handler->check() returns false, one or more of these requirements failed and you can stop the plugin from doing anything, if you like. The next step would be to report the fact that the requirements for you plugin haven't been satisfied.

Messages

Conductor also provides a simple interface to output messages to your end user about why your plugin couldn't run. You can output these messages by using the Messages class and provide it with the failed Checks:

if ( $handler->check() === false ) {
    $messages = new CoenJacobs\Conductor\Messages();
    $messages->setup($handler->getFailures());
}

Each Check is provided with a method that formats a line of text, using the details of your plugin requirements provided to the check. For example, if the WooCommerce plugin wasn't activated and you required it to be at least version 3.1.0, the message output would be:

This plugin requires WooCommerce 3.1.0 or higher to be installed and activated, in order to run.

You can also request the Checks that have failed from the Handler, but using the getFailures() method, to format and output your own messages based on the failed Checks.

What about PHP 5.2?

You might have noticed that all classes in this package are using namespaces and WordPress is notorious for still supporting PHP 5.2 (although that is about to change) and you would be correct! If you really want to support PHP 5.2 in your plugin, or at least make your main plugin file compatible with PHP 5.2, you can use the LegacyCondutor class, which is a PHP 5.2 compatible class to check if the version of PHP being used is at least capable of parsing namespaces.

But wait, Coen, you have this WPupdatePHP project already which does just this?!

Correct again! With the Servehappy project gaining more traction and WordPress' intentions to bump the minimum required version to at least PHP 5.6 soon, I have decided to sunset the WPupdatePHP project. WordPress core can do a far better job at reaching more users of the WordPress software than I can and Servehappy is doing a great job already.

Conductor does more than just check for PHP versions already though. And there is more to come. :)

coenjacobs/conductor 适用场景与选型建议

coenjacobs/conductor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 02 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 coenjacobs/conductor 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-06