Interceptor using PECL AOP extension for PHP AOP.io lib (php-aop).
Provides an abstraction layer of 'PECL AOP extension', with many features to go further in the handling of the AOP with PHP. Beyond the possibilities of the PECL extension.
This package is an adapter for PHP AOP.io lib (an abstraction layer easy to use). The doc below assumes that you have already installed the PHP AOP.io lib.
You can use pecl
sudo pecl install aop-beta
or
Download the AOP PHP extension from github, compile and add the extension to your php.ini
#Clone the repository on your computer
git clone https://github.com/AOP-PHP/AOP
cd AOP
#prepare the package, you will need to have development tools for php
phpize
#compile the package
./configure
make
#before the installation, check that it works properly
make test
#install
make install
Now you can add the following line to your php.ini to enables AOP extension
extension=AOP.so
More doc on PECL AOP repository.
Download pecl-aop-interceptor (and configure your autoloader) or use composer require: "aop-io/pecl-aop-interceptor"
.
use Aop\Aop;
// Init
$aop = new Aop([ 'php_interceptor' => '\PeclAop\PeclAopInterceptor']);
The PECL AOP extension support the wilcard selector, example:
Aop::addBefore('MyClass::get*()', function($jp) {
// your hack here
});
The syntax of pointcuts selectors of PECL AOP extension is documented on the page PECL AOP (pointcuts syntax).
The usage of the AOP abstraction layer is documented on AOP.io.
MIT (c) 2013, Nicolas Tallefourtane.
Nicolas Talle |