marcin_jozwikowski / settings_in_db_bundle
A Symfony2 bundle that allows an easy key-value storage in DB
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:symfony-bundle
This package is auto-updated.
Last update: 2024-12-29 04:42:00 UTC
README
A Symfony2 bundle that allows an easy key-value storage in DB
Installation
- Add as composer dependency:
composer require marcin_jozwikowski/settings_in_db_bundle
- Add in application kernel:
class AppKernel extends Kernel { public function registerBundles() { //... $bundles[] = new \MarcinJozwikowski\SettingsInDBBundle\SettingsInDBBundle(); return $bundles; } }
- Update database schema:
php app/console doctrine:schema:update --force
##Usage
- Access DB stored values through service:
//in controller $val = $this->get('settings_in_db_service')->read('key', 'defaultValue');
##Configuration
Default configuration:
settings_in_db: allow_inserts: true return_null_on_not_found: false read_all_entries_at_first_use: true
- allow_inserts - if set to true, persists a new key-value pair if none is found
- return_null_on_not_found - if nothing found and allow_inserts = false, returns null instead of throwing an exception
- read_all_entries_at_first_use - if set to true loads all records at first use and searches in internal array insted of querying