unitkit/uk-logger-bundle

library for logging to DataBase, notifying to Email or sms

v2.2.0 2019-11-26 09:50 UTC

README

Notifier and Log Bundle for Symfony2.

Requires

  • php: >=5.3.9
  • symfony/symfony: 2.8.*
  • soundasleep/html2text: ~0.3

Install

Composer

#!console

> composer require unitkit/uk-logger-bundle

Setup

app/config.yml

#!yaml

monolog:    
    handlers:  
        email:
            type: service
            id: notifier.email_handler
            channels: notifier
        sms:
            type: service
            id: notifier.sms_handler
            channels: notifier
        system:
            type: service
            id: notifier.system_handler
            channels: notifier

uk_logger:
    notifier:
        default_sender: %mailer_user%
        default_recipient: %mailer_admin%
        note_entity: AppBundle\Entity\Note
        sms: 
            login: %sms.login%
            password: %sms.password%
            sender: %sms.sender%
            gateway: %sms.gateway%

app/AppKernel.php

#!php
<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
   public function registerBundles()
   {
       $bundles = array(           
           new UnitKit\Logger\UkLoggerBundle()
       );
       return $bundles;
   }
}

?>

Usage

Email

#!php
<?php

class DefaultController extends Controller
{

    /**
     * @Route("/", name="homepage")
     */
    public function indexAction(Request $request)
    {        
        $notifier = $this->get('notifier.logger');
        $notifier->email('test from evrostroy_crm', array("from"=>'my@mail.com', "to"=>["your@mail.com"],'subject'=>"header"));
        // replace this example code with whatever you need
        return $this->renderView('default/index.html.twig', array(
            'base_dir' => realpath($this->container->getParameter('kernel.root_dir').'/..'),
        ));
    }

?>