PHP code example of linkorb / app-event-bundle

1. Go to this page and download the library: Download linkorb/app-event-bundle 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/ */

    

linkorb / app-event-bundle example snippets


// config/bundles.php

return [
    // ...
    LinkORB\AppEventBundle\LinkORBAppEventBundle::class => ['all' => true],
];


use LinkORB\AppEvent\AppEventLoggerAwareInterface;
use LinkORB\AppEvent\AppEventLoggerInterface;
use LinkORB\AppEvent\AppEventLoggerTrait;

class MyService implements AppEventLoggerAwareInterface,
    AppEventLoggerInterface
{
    use AppEventLoggerTrait;

    public function myMethod()
    {
        // using the trait makes it very simple to add AppEvent logging:
        $this->log('my.app.event', ['some-info' => ...], 'notice');
    }
}


use LinkORB\AppEventBundle\Logger\AppEventLoggingController;

class MyController extends AppEventLoggingController
{
    public function myAction()
    {
        $this->log('my.app.event', ['some-info' => ...], 'notice');
    }
}


use LinkORB\AppEventBundle\Logger\AppEventLoggingService;

class MyService extends AppEventLoggingService
{
    public function myMethod()
    {
        $this->log('my.app.event', ['some-info' => ...], 'notice');

        // by omission of the third argument, log() will log to the minimum log
        // level, which is whatever you set in the Monolog handler config
        $this->log('my.app.event', ['some-info' => ...);

        // you can also call the logger methods directly, but only do this
        // when the bundle is configured in all environments
        $this->appEventLogger->error('my.app.event', ['some-info' => ...]);
    }
}