定制 drunomics/service-utils 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

drunomics/service-utils

Composer 安装命令:

composer require drunomics/service-utils

包简介

Provides setter injection traits in order to ease dependency injection of services.

README 文档

README

(c) 2017-2025 drunomics GmbH

PHPUnit and code style checks

Provides setter injection traits in order to ease dependency injection of services.

Versions

Major version numbers match Drupal core compatibility, e.g.

 2.x -> Drupal 8.2.x
 3.x -> Drupal 8.3.x
 4.x -> Drupal 8.4.x
 5.x -> Drupal 8.5.x
 6.x -> Drupal 8.6.x
 7.x -> Drupal 8.7.x
 8.x -> Drupal 8.8.x
 9.x -> Drupal 8.9.x
 9.1.x -> Drupal 9.1.x
 9.2.x -> Drupal 9.2.x
 9.3.x -> Drupal 9.3.x
 9.4.x -> Drupal 9.4.x
 10.x -> Drupal 10.x
 11.x -> Drupal 11.x

Scope

This covers traits for services that are missing from core or contrib modules.

Usage

  • Install the package via composer require drunomics/service-utils

  • Just "use" the trait for the service you want to use. The trait provides a suiting getter; e.g., getEntityTypeManager().

Adding a missing trait

  • Just add new trait and add it in the respective namespace. The namespace should match the namespace of the service, but start with \drunomics\ServiceUtils instead of \Drupal.
  • Every trait needs a respective test case. You can simply copy an existing test case and adapt it as necessary.
  • Run tests to ensure everything works as needed and file a PR for your !
  • If your trait covers a contrib module, make sure the contrib module is added as dev-dependency, so its classes are there for running tests.

Running tests

  • Just clone the project and run the following commands from the project directory:
   composer install
   ./vendor/bin/phpunit # or use the shortcut
   composer test

Coding style

To check the coding style for the project's custom code, run PHP code sniffer:

composer cs

To automatically fix the coding style errors (as far as possible), run the PHP code beautifier:

composer cbf

FAQ

  • Why are the traits not added to the upstream source (core or contrib modules) instead?

    This would be the best option, but results in a worse developer experience (DX) while patches are not committed. The goal of this package is to make dependency injection almost as quick as calling out to \Drupal::container(), thus adding in a patch every time a dependency is needed is taking too long and so results in a worse DX.

    The suggested workflow is to quickly add missing traits to this package, so they are immediately available for everyone's use. On a regular basis, patches for traits should be filed against upstream projects in order to improve them and deprecate this package in the long term. Once those patches landed in new upstream releases, the service-utils usages could be replaced and the package can be safely dropped from a project.

  • Why is this no project on drupal.org?

    Because drupal.org has no project type for composer packages and using Github with Travis for tests is convenient.

drunomics/service-utils 适用场景与选型建议

drunomics/service-utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 197.91k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「drupal」 「dependency-injection」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 drunomics/service-utils 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 197.91k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 38
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 6
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2017-02-18