survos/key-value-bundle 问题修复 & 功能扩展

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

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

survos/key-value-bundle

最新稳定版本:1.6.44

Composer 安装命令:

composer require survos/key-value-bundle

包简介

manage dynamic key value(s) list

README 文档

README

Flexible bundle to handle Key Value(s) list, e.g. a dynamic list of ips and paths to block bad bots.

Highly inspired by lsbproject/blacklist-bundle https://github.com/AntoineLemaire/BlacklistBundle

Installation

composer require survos/key-value-bundle

Update database schema

bin/console doctrine:schema:update --force

Purpose

I found myself needing short, configurable lists in different application -- translation memory, spelling checks and most commonly, looking for paths and path patterns to include/exclude during monitoring.

Usage

Add properties by key, which are repeatable.

bin/console survos:kv:add excluded_password password
bin/console survos:kv:add excluded_password admin root 123

Then in code, check

    #[Route('/', name: 'app_homepage', methods: [Request::METHOD_GET])]
    public function index(
                          KeyValueManagerInterface $kvManager,
                          ): Response
    {
        if ($kvManager->has($password, 'excluded_password')) {
            // 
        }
    }

This was originally design for use with BlockBotBundle

bin/console survos:kv:add bad_bot_path_pattern "wp-admin"
bin/console survos:kv:add bad_bot_path_pattern "phpinfo.php"
bin/console survos:kv:add bad_bot_path_pattern "\.php^"
    #[AsEventListener(RequestEvent::class, priority: 10000)]
    public function onKernelRequest(RequestEvent $event): void
    {
        foreach ($this->kvManager->get('bad_bot_path_pattern') as $pattern) {
            if (preg_match("$pattern", $path)) {
                // temporarily block this IP 
            }
        }

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-01