promptphp/intercept-support 问题修复 & 功能扩展

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

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

promptphp/intercept-support

Composer 安装命令:

composer require promptphp/intercept-support

包简介

Shared support utilities and configuration for Intercept middleware packages.

README 文档

README

This package offers shared support utilities and configuration for the Intercept AI Agent middleware collection. It is used internally by Intercept middleware packages.

Most users do not need to install or use this package directly. It is installed automatically when required by an Intercept middleware package.

What this package provides

intercept-support provides shared infrastructure used across the Intercept ecosystem:

  • the shared config/intercept.php configuration file
  • the intercept-config publish tag
  • the InterceptConfig helper for resolving middleware config
  • the InterceptServiceProvider for Laravel package registration

Installation

You usually do not need to install this package directly.

It is installed automatically when installing an Intercept middleware package:

composer require promptphp/intercept-injection-guard

If needed, it can be installed directly:

composer require promptphp/intercept-support

Publishing the config

Intercept uses one shared configuration file:

config/intercept.php

You may publish it with:

php artisan vendor:publish --tag=intercept-config

Publishing config is optional. Every Intercept middleware package has internal defaults and will continue to work even if its config section is missing.

Configuration

The published config file contains global defaults for Intercept middleware.

Example:

<?php

declare(strict_types=1);

return [
    'middleware' => [
        'injection_guard' => [
            'action'             => 'block',
            'patterns'           => [],
            'merge_patterns'     => true,
            'normalise_prompt'   => true,
            'log_prompt_preview' => false,
        ],
    ],
];

Each middleware resolves configuration in this order:

constructor value > config value > internal middleware default

This means users can define global defaults in config/intercept.php, but still override behaviour per agent when creating a middleware instance.

Reading middleware config

Middleware packages should use InterceptConfig::middleware() to read their config safely.

use PromptPHP\Intercept\Support\InterceptConfig;

$config = InterceptConfig::middleware('injection_guard', [
    'action'             => 'block',
    'patterns'           => [],
    'merge_patterns'     => true,
    'normalise_prompt'   => true,
    'log_prompt_preview' => false,
]);

The helper merges the published config section with the middleware's internal defaults.

If the section is missing, the defaults are returned.

Missing config sections

Missing config sections are safe.

For example, if a user publishes config/intercept.php while only using Injection Guard, and later installs PII Redactor, the existing config file may not contain a pii_redactor section.

That is fine. PII Redactor will still work using its internal defaults.

Users only need to add a middleware section to config/intercept.php when they want to customise its global behaviour.

Service provider

This package registers the shared Intercept service provider:

PromptPHP\Intercept\Support\InterceptServiceProvider::class

The provider:

  • merges the default intercept config
  • exposes the intercept-config publish tag

Laravel package auto-discovery should register this provider automatically.

For middleware package authors

Each Intercept middleware package should:

  • require promptphp/intercept-support
  • define its own internal defaults
  • read global config through InterceptConfig::middleware()
  • work even if its config section is missing
  • avoid publishing its own separate config file

Example:

$config = InterceptConfig::middleware(
    'pii_redactor',
    PIIRedactorDefaults::values(),
);

This keeps the Intercept ecosystem consistent while allowing each middleware package to remain independently installable.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固