Home

Awesome

PHP Reflection

npm version Build Status Coverage Status Gitter

Nodejs Reflection API for PHP files based on the php-parser

Install

npm install php-reflection --save

Usage

var reflection = require('php-reflection');
var workspace = new reflection.Repository('/home/devbox/my-project', {
    // actual default options :
    exclude: ['.git', '.svn'],
    include: ['./'],
    ext: [
        '*.php','*.php3','*.php5','*.phtml',
        '*.inc','*.class','*.req'
    ],
    scanVars: true,
    scanExpr: true,
    encoding: 'utf8',
    cacheByFileSize: true
});
var workers = [
    workspace.parse('some-file.php'),
    workspace.parse('another-file.php'),
    workspace.parse('test-file.php')
];
Promise.all(workers).then(function() {
    console.log('-- list of functions :');
    workspace.getByType('function').each(function(fn) {
        console.log('Function Name : ', fn.name);
        console.log('Located into : ', fn.getFile().name);
        console.log('At line : ', fn.position.start.line);
    });
});

Read the API docs for more details.

What it can do

What you could do with it

... if you want to share an idea or your project make a pull request

Benchmark

WIP Disclaimer

This project is actually on it's early alpha stage. It may progress rapidly, so watch the project if you are interested to use it.