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.phar
$ mv phpreflect.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.phar
$ php phpreflect.phar --version

With both methods then you have this output :

phpReflect version 2.0.0 build b45be1d0d1b5a46253f9cda894dd7717f0a64abd

Other alternative installations are possible. Please refer to the documentation for details on how to do this.

With the minimalist JSON file 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.

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 and analyser: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 the analyser:run command.

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                                               46

Structure
  Namespaces                                        16
  Interfaces                                         0
  Traits                                             0
  Classes                                           38
    Abstract Classes                                 5 (13.16%)
    Concrete Classes                                33 (86.84%)
  Methods                                          256
    Scope
      Non-Static Methods                           251 (98.05%)
      Static Methods                                 5 (1.95%)
    Visibility
      Public Method                                232 (90.62%)
      Protected Method                              24 (9.38%)
      Private Method                                 0 (0.00%)
  Functions                                          5
    Named Functions                                  0 (0.00%)
    Anonymous Functions                              5 (100.00%)
  Constants                                        102
    Global Constants                               101 (99.02%)
    Class Constants                                  1 (0.98%)

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.

Choose your way depending of your skill level.

Read more
  • Want to learn more about the command line interpreter (CLI) version, interface that do Reflect an easy tool without to write a line of PHP code, have a look on user’s guide

  • Want to learn more about Reflect architecture and /or you want to extends it to match your needs, have a look on developer’s guide

  • You are a user of previous version 1.9 that is really different, and want to upgrade to the new major version 2, and keep your old environment still running, have a look on migration’s guide