Small WordPress plugin that implements Symfony's dump() command into WordPress, incl. an admin page to list and view dumps, for some developing convinience. Also supports a Twig "dump" filter.
https://codeforge.dev.hellcat.net/Hellcats-Stuff/wp-plugin-sf-vardump
- PHP 88.3%
- Twig 6.9%
- Shell 4.8%
|
|
||
|---|---|---|
| bin | ||
| src | ||
| templates/admin | ||
| .distignore | ||
| .gitignore | ||
| composer.json | ||
| composer.lock | ||
| dist-files.txt | ||
| hcsf-vardumper.php | ||
| license.txt | ||
| readme.txt | ||
| version.json | ||
=== HELLCAT's Symfony Var-Dumper for WordPress ===
Contributors: hellcat, smyrkingfloof
Tags: development, tool
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 8.4
Stable tag: ${VERSION}
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
== Description ==
A small plugin that pulls the Symfony Var-Dumper into WordPress to enable the dump() PHP command and optionally the "|dump" Twig filter.
All dumps are collected in the background, never directly printed out to the site frontend, there is then an admin page under Tools => Dumps that lists all requests for which dumps where collected and where the collected dumps can then be browsed and viewed.
= Enabling the Twig dump filter =
If you're using Twig in your theme or plugin, add this to functions.php or the plugin main php file:
```
add_filter( 'vardumper_collect_twig_instances', function( $twigs ) {
$twigs[] = wp_service('twig');
return $twigs;
});
```
== Installation ==
1. Upload the plugin files to `/wp-content/plugins/hcsf-vardumper`, or install the plugin ZIP file through the WordPress plugins screen.
2. Activate the plugin through the 'Plugins' screen in WordPress.
= Installation via Composer =
The plugin can also be installed via Composer, if you're using that to set up your WP instance.
Add this `repositories` section to your `composer.json` (or add just the repo definition if you already have a repositories section):
{
"repositories": [
{
"type": "composer",
"url": "https://codeforge.dev.hellcat.net/api/packages/Hellcats-Stuff/composer"
}
]
}
Then install the plugin via Composer:
composer require hellcat/hcsf-vardumper
= Enabling the Twig dump filter =
If you're using Twig in your theme or plugin, add this to functions.php or the plugin main PHP file:
add_filter('vardumper_collect_twig_instances', function($twigs) {
$twigs[] = $yourTwigEnvironmentInstanceHere;
return $twigs;
});
= Configuring the path where dump data is saved to =
You can (optionally) change/cofnigure the directory where VarDumper stores all the dumped data.
By default this location is WP_CONTENT_DIR . '/dumps', using the following filter you can set it to any location (webserver process must have write permissions):
add_filter( 'vardumper_dump_directory', function( $dumpDir ) {
return '/your/choosen/path/to/save/dumps';
});
= Usage =
In PHP code, just call `dump($variable)`.
If the Twig filter is enabled, inside a Twig template just use it like `{{ some-variable|dump }}`
Then go to WP-Admin => Tools => Dumps, click on the requests entry in the list to view all collected dumps for that request.
== Changelog ==
= 0.0.4 =
* Path where dump data i stored is now onfigurable ia filter hook.</li>
= 0.0.3 =
* Encrypting dump data files now, to prevent potentially leaking internal information.
* Some internal refactorings.
* Small bug fixes.
= 0.0.2 =
* Bugfix release
= 0.0.1 =
* Initial release
== Credits ==
(c) HELLCAT // released under GPL2 or newer