aop-io/pecl-aop-interceptor

PHP code interceptor for PHP-AOP, based on AOP PHP extension (pecl aop-beta). Provides an abstraction layer of the PHP extension 'PECL AOP', with many features to go further in the handling of the AOP with PHP.

v0.1 2014-08-14 14:40 UTC

This package is auto-updated.

Last update: 2024-11-05 23:11:53 UTC


README

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.

Getting Started

Install PECL AOP

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.

Install pecl-aop-interceptor

Download pecl-aop-interceptor (and configure your autoloader) or use composer require: "aop-io/pecl-aop-interceptor".

Usage

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.

License

MIT (c) 2013, Nicolas Tallefourtane.

Author