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

With both methods then you have this output :

phpReflect version 4.2.2

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

Configuration

With the minimalist JSON file phpreflect.json
{
    "source-providers": [
        {
            "in": ". as current",
            "name": "/\\.(php|inc|phtml)$/"
        }
    ],
    "plugins": [
    ],
    "analysers": [
    ],
    "services": [
    ]
}

Put it in your project’s folder. Alternative locations are possible. Please refer to the documentation for details on how to do this.

The JSON configuration file is no more required for basic usage. Reserved to advanced users.

Structure

source-providers
this entry provide list of your data sources to parse.
plugins
this entry list all plugins added to the core base code of PHP Reflect.
analysers
this entry list all analysers that may be used with the analyser:run command.
services
this entry list all services that may be used with this application.

Execution

With the Reflect source code, invoke the following command :

$ phpreflect analyser:run .

and you should obtain something like this :

Data Source Analysed

Directories                                         22
Files                                               77

Structure
  Namespaces                                        22
  Interfaces                                        10
  Traits                                             0
  Classes                                           67
    Abstract Classes                                 8 (11.94%)
    Concrete Classes                                59 (88.06%)
  Methods                                          312
    Scope
      Non-Static Methods                           299 (95.83%)
      Static Methods                                13 (4.17%)
    Visibility
      Public Method                                268 (85.90%)
      Protected Method                              35 (11.22%)
      Private Method                                 9 (2.88%)
  Functions                                         11
    Named Functions                                  0 (0.00%)
    Anonymous Functions                             11 (100.00%)
  Constants                                         21
    Global Constants                                 0 (0.00%)
    Magic Constants                                  3 (14.29%)
    Class Constants                                 18 (85.71%)
  Tests
    Classes                                          0
    Methods                                          0

Another analyser (loc) is also available, and can be combined or not with structure the default analyser.

With the Reflect source code, invoke the following command :

$ phpreflect analyser:run . loc

and you should obtain something like this :

Data Source Analysed

Directories                                         22
Files                                               77

Size
  Lines of Code (LOC)                             3832
  Comment Lines of Code (CLOC)                     137 (3.58%)
  Non-Comment Lines of Code (NCLOC)               3695 (96.42%)
  Logical Lines of Code (LLOC)                    1210 (31.58%)
    Classes                                       1142 (94.38%)
      Average Class Length                          17
      Average Method Length                          3
    Functions                                       68 (5.62%)
      Average Function Length                        6
    Not in classes or functions                      0 (0.00%)

Complexity
  Cyclomatic Complexity / LLOC                    0.53
  Cyclomatic Complexity / Number of Methods       2.73

Summary

Let’s review what we’ve done :

  • downloaded the latest stable PHAR version.

  • prepared a minimalist JSON configuration file that is OPTIONAL to run Reflect commands.

  • executed your first parse on the Reflect data source.

Next

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