PHP code example of meyfarth / entity-logger

1. Go to this page and download the library: Download meyfarth/entity-logger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

meyfarth / entity-logger example snippets


// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new \Meyfarth\EntityLoggerBundle\MeyfarthEntityLoggerBundle(),
        );
        
        ...
        
        return $bundles;
    }



namespace MyApp\MyBundle\Entity;

use Meyfarth\EntityLoggerBundle\Entity\EntityLoggerInterface;

/**
 * MyEntity
 */
class MyEntity implements EntityLoggerInterface
{
  // Your code
}


/* Note that only the fields modified will be in the data. 
It means that if you only modify the "string" field of your entity, only the "string" field 
will be present in the log.data
*/
array(
    '[FIELDNAME]' => array(
        0 => previousData,
        1 => currentData,
    ),
    '[FIELDNAME2]' => array(
        0 => previousData,
        1 => currentData,
    ),
);