Building an AOP Framework for PHP – Weaving Strategies

In the previous posts (see [1], [2] and [3]) we have learned how to add metadata to classes and how to work with annotations. Now it’s time to talk about adding advices to the objects using these annotations.

Consider two different functions each defined within a separate class – the original code and the advice handling cross-cutting functionality. AOP allows you to execute both of them in one turn, for example the original code followed by the advice code. We have to connect both pieces of code or, in other words, we have to apply the aspect to the original class.

The process of applying aspects to a class is called weaving.