Twig object dumper is a simple Twig extension improving templates debugging : it helps front-end developers to interact the right way with back-end objects., (*1)
Usage
With this code :, (*2)
class Product
{
private $stockQuantity;
public function isInStock() : bool
{
return $this->stockQuantity > 0;
}
}
Standard Twig dump
function displays :, (*3)
Product {#762 ▼
-stockQuantity: 3
}
Which is not a good information : stockQuantity
is private and not usable., (*4)
Whereas the new d
function displays the right way to access object's properties :, (*5)
WizaTech\Product
isInStock() : bool
Installation
$ composer require wizaplace/twig-object-dump
Don't forget to load the new bundle in the app/AppKernel.php
:, (*6)
$bundles = [
// ...
new Wizaplace\TwigObjectDumpBundle\TwigObjectDumpBundle(),
];
This extension checks the twig environment and do nothing if it's set to debug., (*7)
Installation for dev
You can use Vagrant to setup a 'ready for dev' environment :, (*8)
$ cp Vagrantfile.dist Vagrantfile
$ vagrant up
$ vagrant ssh
Load dependencies with Composer :, (*9)
$ composer install
Coding Style
To ensure that you use the right coding standard, use coke
:, (*10)
$ vendor/bin/coke
Credits
Developed by Wizaplace., (*11)
License
This project is licensed under the MIT license., (*12)