kafkiansky/service-locator-interrupter 问题修复 & 功能扩展

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

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

kafkiansky/service-locator-interrupter

Composer 安装命令:

composer require kafkiansky/service-locator-interrupter

包简介

Psalm plugin for Laravel that interrupt service locator calls.

README 文档

README

test Software License Quality Score StyleCI Total Downloads Latest Stable Version

Contents:

Installation

Install this package with Composer:

PHP Version Package Version
PHP ^7.1 composer require kafkiansky/service-locator-interrupter "1.0.4" --dev
PHP ^8.0 composer require kafkiansky/service-locator-interrupter "2.0.1" --dev
PHP <= 8.1 composer require kafkiansky/service-locator-interrupter "2.1.0" --dev
PHP ^8.1 && Laravel ^10.x composer require kafkiansky/service-locator-interrupter "^4.0" --dev
PHP ^8.2 && Laravel ^11.x composer require kafkiansky/service-locator-interrupter "^5.0" --dev

WHY

Laravel-like developers prefer to use some kinds of ioc bad practices. In example: facades, helpers method, container injection and container instances creation anywhere: controllers, services, routes and even in models. You need inject necessary services in method and constructor, not call container to do it for you. Any services must has it own contract, container injection - it's not legal contract, it's hack.

This plugin can found issues of service locator usage - helpers, facades, container injection, container instances creation - and prevent them.

Even if you have your own facade, the plugin will be found it.

Even if you have inherited Container/Application classes, the plugin will be found it.

Even if you have implemented any fo ContainerInterface, the plugin also prevent that.

Dependency Injection

Replacement map

Helper(s)/Facade What you need to use instead
event,\Illuminate\Support\Facades\Event \Illuminate\Events\Dispatcher::class,\Illuminate\Contracts\Events\Dispatcher::class
info,\Illuminate\Support\Facades\Log \Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class
logger,\Illuminate\Support\Facades\Log \Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class
logs,\Illuminate\Support\Facades\Log \Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class
abort, abort_if, abort_unless \Illuminate\Http\Exceptions\HttpResponseException, \Symfony\Component\HttpKernel\Exception\HttpException
auth, \Illuminate\Support\Facades\Auth \Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class
back \Illuminate\Routing\Redirector
broadcast, \Illuminate\Support\Facades\Broadcast \Illuminate\Broadcasting\BroadcastManager, \Illuminate\Contracts\Broadcasting\Factory
cache, \Illuminate\Support\Facades\Cache \Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class
config, \Illuminate\Support\Facades\Config \Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class
cookie, \Illuminate\Support\Facades\Cookie \Illuminate\Cookie\CookieJar::class, \Illuminate\Contracts\Cookie\Factory::class, \Illuminate\Contracts\Cookie\QueueingFactory::class
dispatch, dispatch_now \Illuminate\Contracts\Bus\Dispatcher, \Illuminate\Bus\Dispatcher, \Illuminate\Contracts\Bus\QueueingDispatcher,
redirect, \Illuminate\Support\Facades\Redirect \Illuminate\Routing\Redirector, \Illuminate\Http\RedirectResponse
report \Illuminate\Contracts\Debug\ExceptionHandler
request, \Illuminate\Support\Facades\Request \Illuminate\Http\Request::class, \Symfony\Component\HttpFoundation\Request::class
response, \Illuminate\Support\Facades\Response \Illuminate\Contracts\Routing\ResponseFactory, \Illuminate\Routing\ResponseFactory,
route, \Illuminate\Support\Facades\Route \Illuminate\Routing\UrlGenerator::class, \Illuminate\Contracts\Routing\UrlGenerator::class,
url, \Illuminate\Support\Facades\URL \Illuminate\Routing\UrlGenerator::class, \Illuminate\Contracts\Routing\UrlGenerator::class,
session, \Illuminate\Support\Facades\Session \Illuminate\Session\SessionManager::class, \Illuminate\Session\Store::class, \Illuminate\Contracts\Session\Session::class
trans, trans_choice \Illuminate\Contracts\Translation\Translator, \Illuminate\Translation\Translator,
validator, \Illuminate\Support\Facades\Validator \Illuminate\Validation\Factory::class, \Illuminate\Contracts\Validation\Factory::class
view, \Illuminate\Support\Facades\View \Illuminate\View\Factory::class, \Illuminate\Contracts\View\Factory::class

Testing

$ composer codeception

License

The MIT License (MIT). See License File for more information.

kafkiansky/service-locator-interrupter 适用场景与选型建议

kafkiansky/service-locator-interrupter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.77k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2020 年 08 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-10