Further enhance Tinker summary
Enhances the Tinker summary with:
- Refactored code in a class with separate summary functions for var types
- Function summary (with parameters, etc)
- List closures with the functions (configurable)
- Show docblock for functions (omit if you don't want them)
- Add banner for explanation of the file if wanted
- Added configuration
The idea is that you can make the files as simple or complicated as you wish. If you add types to your parameters, they'll be shown. If you add docblocks to your functions, they'll be shown. If you want to show an intro header, you can.
Configuration
Configuration is used to change how the summary is displayed for your replay file.
You can configure:
-
coloursEnabled
: bool, defaulttrue
-
closuresAsFunctions
: bool, defaulttrue
-
initialSubValueIndent
: string, default" "
-
columnSpacing
: int, default5
-
maxStringLength
: int, default50
-
maxArrayKeyPreview
: int, default5
-
hideSelfFromVars
: bool, defaultfalse
-
varsToIgnore
: array, default[,"e","_","_e","__psysh__","__psysh_include__","__out"]
::config()
must be called statically.
Get current configuration by calling with no parameters:
$configArray = TinkerSummary::config();
All public properties can be set via:
-
::config()
method with an array, egTinkerSummary::config(['coloursEnabled' => true, 'columnSpacing' => 5]);
-
::config()
with named parameters, egTinkerSummary::config(coloursEnabled: true, columnSpacing: 5);
- Directly setting on the instance, eg
TinkerSummary::instance()->coloursEnabled = true;
You can view the current config by calling ::config() with no parameters or by reading the properties directly.
Some sample replay files
Note, that replay-sample-simple.php
expects a running Laravel project (it grabs a user for the example)
- replay-sample-all.php (will just load all the others)
- replay-sample-simple.php
- replay-sample-configuration.php
- replay-sample-functions-and-closures.php
- replay-sample-headers.php
Notes
- Considered updating to Termwind, but for now we still need to support older versions of Laravel.
Sample screenshot |
---|
Edited by Rick Hambrook