https://github.com/marcioalmada/xray
X-Ray - PHP Engine compiler hook API (new)
https://github.com/marcioalmada/xray
php-extension preprocessor
Last synced: 9 months ago
JSON representation
X-Ray - PHP Engine compiler hook API (new)
- Host: GitHub
- URL: https://github.com/marcioalmada/xray
- Owner: marcioAlmada
- License: mit
- Created: 2016-09-22T20:08:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-07-01T20:03:56.000Z (almost 8 years ago)
- Last Synced: 2025-04-14T08:21:45.761Z (about 1 year ago)
- Topics: php-extension, preprocessor
- Language: C
- Homepage: https://github.com/marcioAlmada/xray
- Size: 10.7 KB
- Stars: 20
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
X-Ray
=====
[](https://travis-ci.org/marcioAlmada/xray)
[](http://isitmaintained.com/project/marcioAlmada/xray "Percentage of issues still open")
[](https://github.com/marcioAlmada/xray)
**X-Ray** allows declaration of *Zend Engine* `include()`, `require()` and `eval()` hooks.:
## How to use:
```php
// 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](https://github.com/marcioAlmada/yay).
But this ended up as a more general purpose internal framework so [others projects](https://github.com/phplang/phack) can benefit too.
## Copyright
Copyright (c) 2015-* Márcio Almada. Distributed under the terms of an MIT-style license.
See LICENSE for details.