Skip to content

victorhaggqvist/SettingsBundle

 
 

Repository files navigation

SettingsBundle

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

About

Database centric Symfony2 configuration management bundle. Global and per-entity settings supported.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 98.5%
  • HTML 1.5%