2017 © Pedro Peláez
 

symfony-bundle exceptionizer-bundle

This bundle provides a simple way to play with php Exceptions.

image

mabs/exceptionizer-bundle

This bundle provides a simple way to play with php Exceptions.

  • Tuesday, July 7, 2015
  • by kernel64
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

exceptionizer-bundle SensioLabsInsight

Build Status Scrutinizer Code Quality, (*1)

Play with Exceptions :D This bundle help to get a low coupling between exception class object in your code, (*2)

Installation

Exceptionizer uses Composer, please checkout the composer website for more information., (*3)

The simple following command will install exceptionizer-bundle into your project. It also add a new entry in your composer.json and update the composer.lock as well., (*4)

$ composer require 'mabs/exceptionizer-bundle'

Then, you can enable it in your kernel:, (*5)

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        ...
        new Mabs\ExceptionizerBundle\MabsExceptionizerBundle(),
        ...

Usage

Now you can use Exceptionizer service to throw Exceptions:, (*6)

$this->container->get('exceptionizer')
->throwException('\\Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException', array('Your message'));

OR define your Exception in your config.yml file like this :, (*7)

mabs_exceptionizer:
    exceptions:
        bar_code_exception:
            class: Mabs\BarCodeBundle\Exception\BarCodeException
            arguments:                          # optional
                message: "bar code exception"   # optional
                code:  0                        # optional

and pass the config key to the service:, (*8)

$this->container->get('exceptionizer')->throwException('bar_code_exception');

Events and listener:

ExceptionizerBundle provide two events:, (*9)

namespace Mabs\ExceptionizerBundle;


final class ExceptionizerEvents
{

    const EXCEPTIONIZER_PRE_THROW = 'exceptionizer.pre_throw';

    const EXCEPTIONIZER_POST_CATCH = 'exceptionizer.post_catch';
}

exceptionizer.pre_throw : before throw Exception, (*10)

exceptionizer.post_catch: (will be documented later when we speak about the Exception Catcher), (*11)

Now you can create Listeners to do a specific job when an exception will be thrown ;) and to learn more about the EventDispatcher Component in symfony2 pleaze read the documentation, (*12)

License

This bundle is available under the MIT license., (*13)

The Versions

07/07 2015

dev-master

9999999-dev

This bundle provides a simple way to play with php Exceptions.

  Sources   Download

MIT

The Requires

 

by Mohamed Aymen Ben Slimane

php bundle symfony exception catch throw exceptionizer