gridonic/database-utils-service-provider

Database utilities service provider for Silex. Includes some database commands and adds fixtures for your database.

1.0.9 2015-02-20 09:11 UTC

This package is not auto-updated.

Last update: 2024-04-09 00:21:46 UTC


README

Build Status

This is a simple collection of utilities for your database for Silex and Doctrine DBAL.

Install

As usual, just include gridonic/database-utils-service-provider in your composer.json , and register the service.

$app->register(new \Gridonic\Provider\DatabaseUtilsServiceProvider(), array(
    'database_utils.fixtures'       => PATH_RESOURCES . '/fixtures/*.yml',
    'database_utils.password_keys'  => array('password'),
    'database_utils.security.salt'  => 'abcd',
));

Parameters

An overview of the possible parameters

database_utils.fixtures

required for fixtures All your fixtures-files.

database_utils.password_keys

optional An array of keys of table-columns, in which you are saving passwords. The values will be automatically encoded before insert.

database_utils.security.salt

required for database_utils.password_keys To encode the passwords, we use this salt.

Commands

When you have registered the ConsoleServiceProvider correct, you can use the following commands in your console.

database:drop

Clears your database

database:reset

Resets your database. Means:

database:fixtures:load

Loads example-data from your fixtures-files into the database.

when you set the password_keys and the salt, all the values for the password_keys (p.E. 1234 as password) will be encoded before insert. All the passwords will be encoded by the Silex\Provider\SecurityProvider. You have to register the SecurityProvider before you can use this function.

Example 01_test.yml

test:
    -
        id: 1
        created: 1000000000
        username: abc
        email: abc@abc.com
        password: 1234
    -
        id: 2
        created: 1000000001
        username: def
        email: def@abc.com
        password: 1234

Example to register the SecurityProvider

$app->register(new Silex\Provider\SecurityServiceProvider(), array(
    'security.firewalls' => array(
        'private' => array(
            'pattern' => '^/admin',
            'http' => true,
            'users' => array(
                'admin' => array('ROLE_ADMIN', 'ASv5vPSea0zB3EIpIB/mLOFAxkMIfh1EkTozyenPTZa0mGAiTC3n+mCAEdcYiITruuPaFb6GWFDiyF5fvJtqOg=='),
            ),
        ),
    ),
));

Licence

The DatabaseUtilsServiceProvider is licensed under the MIT license.