2017 © Pedro Peláez
 

symfony-bundle db-bundle

Doctrine DBAL Helper Bundle. Providing extra functionality for the DBAL

image

rollerworks/db-bundle

Doctrine DBAL Helper Bundle. Providing extra functionality for the DBAL

  • Wednesday, January 1, 2014
  • by sstok
  • Repository
  • 0 Watchers
  • 0 Stars
  • 19 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

RollerworksDBBundle

UserErrorExceptionListener

This listener listens to DBAL related Exceptions and looks for an so-called user-error., (*1)

Currently only PostgreSQL is supported., (*2)

An user-error is an exception/error thrown by an DB used-defined function, and can be seen as a system exception, so its not intended for validating basic user-input., (*3)

Usage may include an access-violation or none-existent relation., (*4)

Installation

To install RollerworksDBBundle with Composer add the following to your composer.json file:, (*5)

// composer.json
{
    // ...
    require: {
        // ...
        "rollerworks/db-bundle": "master-dev"
    }
}

NOTE: Please replace master-dev in the snippet above with the latest stable branch, for example 1.0.*., (*6)

Then, you can install the new dependencies by running Composer's update command from the directory where your composer.json file is located:, (*7)

$ php composer.phar update

Now, Composer will automatically download all required files, and install them for you. All that is left to do is to update your AppKernel.php file, and register the new bundle:, (*8)

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Rollerworks\Bundle\DBBundle\RollerworksDBBundle(),
    // ...
);

Step 1 (alternative): Using deps file (Symfony 2.0.x)

First, checkout a copy of the code. Just add the following to the deps file of your Symfony Standard Distribution:, (*9)

[RollerworksDBBundle]
    git=http://github.com/rollerworks/RollerworksDBBundle.git
    target=/bundles/Rollerworks/Bundle/DBBundle

NOTE: You can add version tag in the snippet above with the latest stable branch, for example version=origin/2.0., (*10)

Then register the bundle with your kernel:, (*11)

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Rollerworks\Bundle\DBBundle\RollerworksDBBundle(),
    // ...
);

Make sure that you also register the namespace with the autoloader:, (*12)

<?php

// app/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Rollerworks'              => __DIR__.'/../vendor/bundles',
    // ...
));

Now use the vendors script to clone the newly added repositories into your project:, (*13)

$ php bin/vendors install

Step 1 (alternative): Using submodules (Symfony 2.0.x)

If you're managing your vendor libraries with submodules, first create the vendor/bundles/Rollerworks/Bundle directory:, (*14)

``` bash $ mkdir -pv vendor/bundles/Rollerworks/Bundle, (*15)


Next, add the necessary submodule: ``` bash $ git submodule add git://github.com/rollerworks/RollerworksDBBundle.git vendor/bundles/Rollerworks/Bundle/DBBundle

Step2: Configure the autoloader

Add the following entry to your autoloader:, (*16)

``` php <?php // app/autoload.php, (*17)

$loader->registerNamespaces(array( // ... 'Rollerworks' => DIR.'/../vendor/bundles', // ... ));, (*18)


### Step3: Enable the bundle Finally, enable the bundle in the kernel: ``` php <?php // in AppKernel::registerBundles() $bundles = array( // ... new Rollerworks\Bundle\DBBundle\RollerworksDBBundle(), // ... );

Congratulations! You're ready!, (*19)

Step4: Configure the bundle

By default the exception listerner only listens to \PDOException and \Doctrine\DBAL\Driver\OCI8\OCI8Exception. And only tries to parse the error message when its starts with 'app-exception: '., (*20)

You may change this by adding this to your configuration., (*21)

``` yaml, (*22)

app/config/config.yml

rollerworks_db: user_exception_listener: check_prefix: 'my-app-exception: ' check_class_in: [ '\PDOException' ] ```, (*23)

The Versions

01/01 2014

dev-master

9999999-dev

Doctrine DBAL Helper Bundle. Providing extra functionality for the DBAL

  Sources   Download

MIT

The Requires

 

by Sebastiaan Stok

bundle doctrine symfony dbal