marc/xray

X-Ray allows declaration of Zend Engine include() and eval() hooks.

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 20

Watchers: 5

Forks: 0

Open Issues: 0

Language:C

Type:extension

dev-master 2018-07-01 20:03 UTC

This package is auto-updated.

Last update: 2024-10-18 06:42:32 UTC


README

Build Status Percentage of issues still open License

X-Ray allows declaration of Zend Engine include(), require() and eval() hooks.:

How to use:

// adding a compiler hook:
xray\set_compiler_hook(function(string $source, string $filename = null) : string {
    if ($filename === null)  {
        // here we intercept source included through eval()
        // do transformations on $source and return the new $source to be included        
    }
    else {
        // here we intercept source included from a *.php file
        // do transformations on $source and return the new $source to be included
    }
});

// removing the compiler hook:
$hook = xray\restore_compiler_hook();

How to install:

git clone https://github.com/marcioAlmada/xray
cd xray
phpize
./configure
make
sudo make install

Finally add extension=xray.so to your /etc/php.ini

Windows Support

Pull requests welcome. Anyone?

Why?

A compiler hook API was needed in order to have a decent infrastructure for YAY. But this ended up as a more general purpose internal framework so others projects can benefit too.

Copyright

Copyright (c) 2015-* Márcio Almada. Distributed under the terms of an MIT-style license. See LICENSE for details.