wizaplace/twig-object-dump

Simple Twig extension improving templates debugging

Installs: 44 224

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 21

Forks: 1

Open Issues: 0

Type:symfony-bundle

v1.0.0 2017-02-24 13:47 UTC

This package is auto-updated.

Last update: 2024-12-08 07:49:45 UTC


README

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.

Usage

With this code :

class Product
{
    private $stockQuantity;

    public function isInStock() : bool
    {
        return $this->stockQuantity > 0;
    }
}

Standard Twig dump function displays :

Product {#762 ▼
  -stockQuantity: 3
}

Which is not a good information : stockQuantity is private and not usable.

Whereas the new d function displays the right way to access object's properties :

WizaTech\Product
    isInStock() : bool

Installation

$ composer require wizaplace/twig-object-dump

Don't forget to load the new bundle in the app/AppKernel.php :

$bundles = [
    // ...
    new Wizaplace\TwigObjectDumpBundle\TwigObjectDumpBundle(),
];

This extension checks the twig environment and do nothing if it's set to debug.

Installation for dev

You can use Vagrant to setup a 'ready for dev' environment :

$ cp Vagrantfile.dist Vagrantfile
$ vagrant up
$ vagrant ssh

Load dependencies with Composer :

$ composer install

Coding Style

To ensure that you use the right coding standard, use coke :

$ vendor/bin/coke

Credits

Developed by Wizaplace.

License

This project is licensed under the MIT license.