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.4.0.phar
$ mv phpreflect-2.4.0.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.4.0.phar
$ php phpreflect-2.4.0.phar --version
With both methods then you have this output :
phpReflect version 2.4.0 build ...
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:runandanalyser:listcommands wouldn’t be available. - analysers
-
this entry list all analysers that may be used with the
analyser:runcommand.Don’t miss it, else you could not run theanalyser:runcommand.
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 16
Files 47
Structure
Namespaces 16
Interfaces 0
Traits 0
Classes 39
Abstract Classes 5 (12.82%)
Concrete Classes 34 (87.18%)
Methods 269
Scope
Non-Static Methods 263 (97.77%)
Static Methods 6 (2.23%)
Visibility
Public Method 243 (90.33%)
Protected Method 26 (9.67%)
Private Method 0 (0.00%)
Functions 5
Named Functions 0 (0.00%)
Anonymous Functions 5 (100.00%)
Constants 105
Global Constants 104 (99.05%)
Class Constants 1 (0.95%)
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.