Giter VIP home page Giter VIP logo

eventdatabundle's Introduction

README

What is it?

This is a library that allows for integration of the EventData library (https://github.com/michaelesmith/EventData) by adding a panel to the web profiler

Installation

Use Composer (recommended)

Get Composer at http://getcomposer.org

php composer.phar require "michaelesmith/event-data-bundle" "dev-master"

Examples

Example configuration

# app/config/config.yml
    events_storage:
        class: MS\EventData\Storage\KeenIO
        arguments: [ @keen_io ]

    events_logger:
        class: MS\EventData\Logger\PSRLogger
        arguments: [@logger, @events]

    events_logger_generic:
        class: MS\EventData\Logger\GenericLogger

    events_data_collector:
        class: MS\Bundle\EventDataBundle\DataCollector\EventDataCollector
        arguments: [@events, @events_logger_generic]
        tags:
            - { name: data_collector, template: "MSEventDataBundle:Collector:events", id: "event_data" }

    events_data_listener:
        class: MS\Bundle\EventDataBundle\EventListener\EventDataListener
        arguments: [@events]
        tags:
            -
                name: kernel.event_listener
#                event: kernel.finish_request
                event: kernel.terminate
                method: flush
                priority: 0

    events:
        class: MS\EventData\EventDataManager
        arguments: [@events_storage]
        calls:
            - [addLogger, [@events_logger]]
            - [addLogger, [@events_logger_generic]]
            - [setDebug, [%kernel.debug%]]
            - [setDelayed, ["@=not parameter('kernel.debug')"]]

To use the keen storage you will to require the keenIO bundle"keen-io/keen-io-bundle": "~1.0". This also configures a PSRLogger with the default logger instance. The generic logger is used by the profiler panel. The data collector is what powers the profiler panel. The event listener allows the events to be flushed to the storage after the response has been sent to the user to prevent a delay. For the data collector to have the response you need to use kernel.finish_request which is called just before the response is sent, in production you should use kernel.terminate which is called after the response is sent.

To use it in an action you can simple do:

$this->container->get('events')->store(new Event('page_view', array('homepage')));

The event class passed to it can be anything that implements the \MS\EventData\Event\EventInterface or extends \MS\EventData\Event\Event. I have found it helpful to use my own Event class so it can automatically add data such as current time, user ip or logged in username.

eventdatabundle's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.