Download the PHP package kode/aop without Composer
On this page you can find all versions of the php package kode/aop. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package aop
Kode/AOP - PHP 8.1+ 轻量级 AOP 框架
基于 PHP 8.1+ 原生属性(Attribute)实现的轻量级、高性能、高扩展性 AOP(面向切面编程)组件。
✨ 特性
- 原生支持:基于 PHP 8.1+ 原生属性(Attribute)实现,IDE 友好
- 轻量级:依赖
kode/attributes包,无其他框架依赖 - 高性能:使用缓存机制避免重复反射操作
- 类型安全:充分利用 PHP 8.1+ 的类型系统,支持 readonly 属性
- 扩展性强:支持前置通知(Before)、后置通知(After)、环绕通知(Around)
- 优先级控制:支持通过
#[Priority]注解控制切面执行顺序 - 切入点表达式:支持通配符匹配,灵活定义切入点
📦 安装
🚀 快速开始
1. 创建切面类
2. 配置 AOP 内核
3. 使用代理对象
📖 详细文档
通知类型
Before(前置通知)
在目标方法执行前执行,可以修改方法参数或执行预处理逻辑。
After(后置通知)
在目标方法执行后执行(无论是否抛出异常),适用于资源清理、日志记录等场景。
Around(环绕通知)
环绕目标方法执行,可以完全控制方法的执行流程。
优先级控制
使用 #[Priority] 注解控制切面执行顺序,数字越小优先级越高。
切入点表达式
支持的切入点表达式语法:
| 表达式 | 说明 | 示例 |
|---|---|---|
execution(* Class->method(..)) |
执行方法 | execution(* UserService->createUser(..)) |
execution(* Class->*(..)) |
类的所有方法 | execution(* UserService->*(..)) |
execution(* Namespace\*->*(..)) |
命名空间下所有类的所有方法 | execution(* App\Service\*->*(..)) |
within(Namespace\*) |
命名空间下所有类 | within(App\Controller\*) |
通配符说明:
*:匹配任意数量的任意字符..:匹配任意参数列表?:匹配单个任意字符
JoinPoint API
JoinPoint 类提供了丰富的方法来获取方法调用的上下文信息:
ProceedingJoinPoint API
ProceedingJoinPoint 继承自 JoinPoint,额外提供了控制原方法执行的能力:
🏗️ 核心组件
🔧 框架集成
Laravel 集成
Symfony 集成
Hyperf 集成
🧪 测试
运行测试:
运行代码覆盖率:
静态分析:
📋 系统要求
- PHP >= 8.1
- Composer >= 2.0
- kode/attributes ^1.0
📄 许可证
Apache License 2.0
🤝 贡献
欢迎提交 Issue 和 Pull Request!
📮 联系方式
- Email: [email protected]
- GitHub: https://github.com/kodephp/aop
All versions of aop with dependencies
PHP Build Version
Package Version
The package kode/aop contains the following files
Loading the files please wait ...