https://github.com/xtompie/aop
https://github.com/xtompie/aop
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/xtompie/aop
- Owner: xtompie
- Created: 2023-02-04T23:02:16.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-05T20:48:36.000Z (over 3 years ago)
- Last Synced: 2025-10-03T09:10:38.967Z (10 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Aop - Aspect-Orientend Programing for PHP
This library require changes in the original source code.
In simplified and generalized term AOP is Publish/Subscribe system with Middlewares.
## Requiments
PHP >= 8.0
## Installation
Using [composer](https://getcomposer.org/)
```
composer require xtompie/aop
```
## Docs
### 1. Creating Aspect
Aspect is a class implementing `Aspect` interface.
```php
$invocation->joinpoint(),
'args' => $invocation->args(),
'result' => $result,
]);
return $result;
}
}
```
Pointcut is a pattern that can match Joinpoint.
Pointcut can have a `*` character that describes any character in any number of occurrences.
If Pointcut dont have `*` it is equal to Joinpoint.
There is only one type of Advice - around. Before and after can be achive manualy or using `GenericAspect`.
### 2. Create AOP system
```php
__invoke($joinpoint, $args, $main);
}
```
### 3. Create joinpoint in service
```php
withArgs([$invocation->args()[0] + 5]);
return $invocation();
}
}
```
### 5. Changing aspect orders
The higher the order, the closer it is to the main invocation.
```php
args()[0] - 10;
}
}
```