承接 zeecoder/good-to-know 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

zeecoder/good-to-know

Composer 安装命令:

composer require zeecoder/good-to-know

包简介

A solution for collecting good-to-know facts to show to users.

README 文档

README

Build Status Version SensioLabsInsight

Description

The original purpose of this project was to have an easy way of collecting good-to-know facts for certain pages / features that need explanation.

To achieve that, the code was engineered in a very generic way:

  • Fetch all the data with a repository call,
  • Apply transformations on the returned collection and/or it's elements via Listeners.

Since the code uses listeners, it's very easy to add / remove functionality.

Built-in features

  • Parameter injection
  • Translation support

Integrations

A simple example

# good-to-know.yml
# When loaded and fetched by the `YamlFileRepository`, these will be converted
# into `Fact` objects.
- text: Something important.
  groups: [feature1]
- text: Something important about feature2.
  groups: [feature2]
- text: Something important about both features.
  groups: [feature1, feature2]
use ZeeCoder\GoodToKnow\GoodToKnow;
use ZeeCoder\GoodToKnow\Repository\YamlFileRepository;

// The `GoodToKnow` object acts as a wrapper around the given repository.
// Every call made to this object is forwarded to the repository.
// The listeners are fired after getting the result collection from the
// repository.
$gtk = new GoodToKnow(
    new YamlFileRepository(__DIR__ . '/good-to-know.yml')
    // A dispatcher could be passed as the second argument.
    // If no dispatcher is given, one gets created
);

// `findAllByGroups` is a method in the `YamlFileRepository` repository.
// It returns a collection of `ZeeCoder\GoodToKnow\Fact` objects.
// (In this case, an `\SplObjectStorage`.)
$collection = $gtk->findAllByGroups([
    'feature1'
]);

// The collection would have the "Something important." and
// "Something important about both features." texts as Fact objects.

Listeners

Without listeners, the main GoodToKnow object doesn't do anything apart from forwarding calls to the repository.

It gets interesting, when you throw some listeners into the mix.

The ParameterListener

This listener's job is to inject registered parameters into good-to-know strings.

# good-to-know.yml
# When loaded and fetched by the `YamlFileRepository`, these will be converted
# into `Fact` objects.
- text: Something important. %lorem%!
  groups: [feature1]
- text: Something important about feature2.
  groups: [feature2]
- text: Something important about both features: The upload max filesize is: %upload_max_filesize%.
  groups: [feature1, feature2]
// ...
// Assuming the example above

use ZeeCoder\GoodToKnow\ParameterInjector;
use ZeeCoder\GoodToKnow\Events;
use ZeeCoder\GoodToKnow\Listener\ParameterListener;

// Getting the dispatcher, since we didn't provide one explicitly.
$dispatcher = $gtk->getDispatcher();

// Creating the ParameterInjector
$parameterInjector = (new ParameterInjector())
    // Registering parameters
    ->addParameter('%lorem%', 'ipsum')
    ->addParameter('%upload_max_filesize%', function() {
        return ini_get('upload_max_filesize');
    })
;

// Adding the listener.
// The TRANSFORM event is fired for every result returned by the repository.
$dispatcher->addListener(
    Events::TRANSFORM,
    new ParameterListener($parameterInjector)
);

$collection = $gtk->findAllByGroups([
    'feature1'
]);

// Now the collection would have the "Something important. ipsum!" and
// "Something important about both features: The upload max filesize is: 2M."
// texts as Fact objects.

The TranslationListener

This listener assumes a translator implementing Symfony's TranslatorInterface.

use ZeeCoder\GoodToKnow\Events;
use ZeeCoder\GoodToKnow\Listener\TranslationListener;

// Getting the dispatcher, since we didn't provide one explicitly.
$dispatcher = $gtk->getDispatcher();

$dispatcher->addListener(
    Events::TRANSFORM,
    new TranslationListener(
        // Assuming we have a Symfony `$translator` object.
        $translator
        // The second parameter, is the translation domain. Default: "good-to-know"
    )
);

// Now all Fact texts will be translated.

Important

The TranslationListener must be registered first, or with a higher priority than the ParameterListener.

That way parameters can be injected after translations occured.

Source

Consider looking at the source files, in order to enhance / alter basic functionality.

(Creating a Database Repository for example.)

License

MIT

zeecoder/good-to-know 适用场景与选型建议

zeecoder/good-to-know 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.4k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 05 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 zeecoder/good-to-know 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-25