Download
We distribute a PHP Archive (PHAR) that contains all required dependencies of PHP Reflect bundled in a single file.
Make it executable, and put it into your $PATH
.
$ chmod +x phpreflect-2.6.3.phar
$ mv phpreflect-2.6.3.phar /usr/local/bin/phpreflect
$ phpreflect --version
You can also immediately use the PHAR after you have downloaded it.
$ wget http://bartlett.laurent-laville.org/get/phpreflect-2.6.3.phar
$ php phpreflect-2.6.3.phar --version
With both methods then you have this output :
phpReflect version 2.6.3
Other alternative installations are possible. Please refer to the documentation for details on how to do this.
Configuration
phpreflect.json
{
"source-providers": [
{
"in": ". as current",
"name": "/\\.(php|inc|phtml)$/"
}
],
"plugins": [
{
"name": "Analyser",
"class": "Bartlett\\Reflect\\Plugin\\Analyser\\AnalyserPlugin"
}
],
"analysers" : [
{
"name": "Structure",
"class": "Bartlett\\Reflect\\Analyser\\StructureAnalyser"
}
]
}
Put it in your project’s folder. Alternative locations are possible. Please refer to the documentation for details on how to do this.
Structure
- source-providers
-
this entry provide list of your data sources to parse.
Like Reflect always needs a JSON file to run, Remi Collet shared a workaround solution exposed here that allows to run :
$ phpreflect analyser:run .
- plugins
-
this entry list all plugins added to the core base code of PHP Reflect.
Don’t forget to add at least this default content, else the
analyser:run
andanalyser:list
commands wouldn’t be available. - analysers
-
this entry list all analysers that may be used with the
analyser:run
command.Don’t miss it, else you could not run theanalyser:run
command.
Execution
With a default phpreflect.json
as detailed above, put in the src/
folder of the
Reflect source code, and invoke the following command :
$ phpreflect analyser:run .
and you should obtain something like this :
Data Source Analysed Directories 17 Files 53 Structure Analysis Namespaces 17 Interfaces 10 Traits 0 Classes 51 Abstract Classes 4 (7.84%) Concrete Classes 47 (92.16%) Methods 323 Scope Non-Static Methods 316 (97.83%) Static Methods 7 (2.17%) Visibility Public Method 288 (89.16%) Protected Method 32 (9.91%) Private Method 3 (0.93%) Functions 6 Named Functions 0 (0.00%) Anonymous Functions 6 (100.00%) Constants 30 Global Constants 14 (46.67%) Class Constants 16 (53.33%)
Summary
Let’s review what we’ve done :
-
downloaded the latest stable PHAR version.
-
prepared your JSON configuration file that is required to run Reflect commands.
-
executed your first parse on the Reflect data source.
Next
Choose your way depending of your skill level.