dmishh/settings-bundle

Database centric Symfony2 configuration management. Global and per-user settings supported. It just works.

Installs: 4 394

Dependents: 4

Stars: 25

Watchers: 6

Forks: 13

Open Issues: 14

Type: symfony-bundle

2.0.0-beta1 2015-08-24 04:11 UTC

README

Bundle is used for storing configuration with Symfony2 in database using Doctrine2 ORM.

Build Status SensioLabsInsight

Thanks to Tobias Nyholm and Artem Zhuravlov for contribution.

Features

  • Easy-to-use (Twig extension, container service)
  • Fast and extensible
  • Settings scopes per user, global or all
  • Settings validation using full power of Symfony2 Form Component
  • 2 serialization mechanisms in DB: PHP's native serialize() and JSON + you can write your own
  • Settings caching

Quick usage examples

Symfony controller:

// Global settings
$this->get('settings_manager')->set('name', 'foo');
$this->get('settings_manager')->get('name'); // returns 'foo'

// User settings
$this->get('settings_manager')->get('name', $user); // returns global 'foo'
$this->get('settings_manager')->set('name', 'bar', $user);
$this->get('settings_manager')->get('name', $user); // returns 'bar'

Twig template:

{# Global setting #}
{{ get_setting('some_setting') }} {# => 'value' #}

{# User setting #}
{{ get_setting('some_user_setting', app.user) }} {# => 'value' #}

See the general usage documentation for more examples.

Documentation

Roadmap and contribution

Please, do not hesitate to report bugs or send pull requests. It will help to motivate me to support library better than anything else :)

Version 2.0.0-dev
  • Added optional caching
  • New interface for your entity. We are no longer using UserInterface. Use SettingsOwnerInterface instead.
  • Changed behavior of SettingsManager::all. It will not return global config if the user/local values are missing
  • Added possibility to add default value as third parameter on SettingsManager::get
Version 1.0.2-1.0.7
  • Minor code improvements and bug fixes
  • System messages translations to en, it, es, fr, de, ru, uk, sv languages
Version 1.0.1
  • Ability to choose serialization mechanism (php or json)
  • Ability to add constraints to validation
Version 1.0.0
  • First stable version

Upgrade from 1.0.*

Make sure to read the UPGRADE.md to successfully migrate your application.

License

The MIT License. For the full text of license, please, see LICENSE

© 2013-2015 Dmitriy Scherbina