This is a simple collection of utilities for your database for Silex and Doctrine DBAL.
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',
));
An overview of the possible parameters
required for fixtures All your fixtures-files.
optional An array of keys of table-columns, in which you are saving passwords. The values will be automatically encoded before insert.
required for database_utils.password_keys
To encode the passwords, we use this salt.
When you have registered the ConsoleServiceProvider correct, you can use the following commands in your console.
Clears your database
Resets your database. Means:
- Drops your database
- Migrates the database (uses MigrationServiceProvider)
- Loads example-data into your database
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.
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
$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=='),
),
),
),
));
The DatabaseUtilsServiceProvider is licensed under the MIT license.