![]() | |
Reflect may used an optional config file in JSON format.
It could be found either in the current, By setting the E.g: And by setting the E.g: E.g: Take care of different PATH_SEPARATOR and DIRECTORY_SEPARATOR in each platform. |
The minimalist JSON file phpreflect.json
is :
{ "source-providers": [ { "in": ". as current", "name": "/\\.(php|inc|phtml)$/" } ], "plugins": [ ], "analysers": [ ], "services": [ ] }
analyser:run
command.
There are lot of way to filter your data source. Each rule follow the syntax of Symfony Finder Component.
The Location is the only mandatory criteria. It tells the Finder which directory to use for the search.
In a simple directory.
{ "in": ". as current" }
![]() | |
If you want to identify a data source easily by a short name, the alias (right of |
Search in several locations.
{ "in": ". as current", "in": "src/" }
Use wildcard characters to search in the directories matching a pattern:
{ "in": "src/Bartlett/R*" }
Search directly in archives (phar, zip, tar) with the phar://
protocol.
{ "in": "phar://path/to/archive.zip" }
Restrict files by name and/or extension.
{ "in": "phar://path/to/archive.zip", "name": "*.php" }
Restrict files by size.
{ "in": "phar://path/to/archive.zip", "name": "*.php", "size": "< 10K" }
Restrict files by last modified dates.
{ "in": ". as current", "date": "since yesterday" }
By default, the Finder recursively traverse directories.
Restrict the depth of traversing.
{ "in": ". as current", "depth": "< 3" }
Restrict location by only one directory.
{ "in": ". as current", "exclude": "vendor" }
Restrict location by 1 or more directories.
{ "in": ". as current", "exclude": ["vendor", "tests"] }
There are a number of optional plugins you can use along with Reflect to add more capabilities.
Take an example with the Logger
plugin.
In your phpreflect.json
configuration file, add in plugins
section the following entry:
{ "name": "Logger", "class": "Bartlett\\Reflect\\Plugin\\LogPlugin" }
name
key is (since version 3.0.0-alpha1) comment only.
class
key identify the name of the class that implement the plugin features (must be fully qualified).
![]() | |
The |
![]() | |
Available since version 2.3.0, but location changed since version 3.0.0-alpha1 |
In your phpreflect.json
configuration file, add in plugins
section the following entry:
{ "name": "Cache", "class": "Bartlett\\Reflect\\Plugin\\CachePlugin", "options": { "adapter": "DoctrineCacheAdapter", "backend": { "class": "Doctrine\\Common\\Cache\\FilesystemCache", "args": [ "%{TEMP}/bartlett/cache" ] } } }
![]() | |
You may use any environment variable that will be replaced, at run-time, by their value. E.g: |
![]() | |
Since release 2.3.0, the |
![]() | |
If you want to used the same options (Doctrine adapter with file cache) as above, you can used shortcut syntax like this. { "name": "Cache", "class": "Bartlett\\Reflect\\Plugin\\CachePlugin", "options": [] } |
In previous configuration we used the Doctrine Cache adapter and its File system backend. See the same configuration applied with other SAPI, in Section 19.3, “File cache”
![]() | |
Available since version 2.4.0, but location and options changed since version 3.0.0-alpha1 |
In your phpreflect.json
configuration file, add in plugins
section the following entry:
{ "name": "Log", "class": "Bartlett\\Reflect\\Plugin\\LogPlugin" }
Where options
key identify an optional class logger (fully qualified. E.g YourNamespace\YourLogger
).
When options
key is not provided, log plugin used the default Reflect logger bundled with distribution.
See Bartlett\Reflect\Plugin\Log\DefaultLogger
that write results to the error log system.
See the Developer Guide for definition examples of some loggers Section 20.3, “Using your private logger” or Section 20.4, “Using Monolog”
There are two default analysers you can use, but you are free to add your owns.
In your phpreflect.json
configuration file, add in analysers
section (for example) the following entry:
{ "name": "MyAnalyser", "class": "Your\\Analysers\\MyAnalyser" }
name
key is (since version 3.0.0-alpha1) comment only.
class
key identify the name of the class that implement your analyser (must be fully qualified).
Your analyser should implement both interfaces Bartlett\Reflect\Analyser\AnalyserInterface
and PhpParser\NodeVisitor
.
Then to use it in command line :
$ phpreflect analyser:run /path/to/datasource my
![]() | |
|