PHPackages                             vbee/settingbundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vbee/settingbundle

AbandonedArchivedSymfony-bundle[Utility &amp; Helpers](/categories/utility)

vbee/settingbundle
==================

A simple setting bundle for Symfony2

1.0(12y ago)3182[1 issues](https://github.com/VincentBee/VBeeSettingBundle/issues)MITPHPPHP &gt;=5.3.0

Since Apr 8Pushed 11y ago2 watchersCompare

[ Source](https://github.com/VincentBee/VBeeSettingBundle)[ Packagist](https://packagist.org/packages/vbee/settingbundle)[ RSS](/packages/vbee-settingbundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (5)Used By (0)

VBeeSettingBundle
=================

[](#vbeesettingbundle)

This bundle simply allow to manage settings in your application trough the database. That make it easier to manage during the application running than parameters files.

[![Build Status](https://camo.githubusercontent.com/5276abf1cb68941d82676a970c4ae859545cf88eb6e439586793be305c70d6d4/68747470733a2f2f7472617669732d63692e6f72672f56696e63656e744265652f5642656553657474696e6742756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/VincentBee/VBeeSettingBundle)

Installation
============

[](#installation)

Composer.json:

```
"vbee/settingbundle": "dev-master"

```

Update your vendors:

```
php composer.phar update vbee/settingbundle

```

Update your configuration file: app/config/config.yml

```
v_bee_setting:
    orm: doctrine # possible values = doctrine and mongodb

```

app/AppKernel.php:

```
new VBee\SettingBundle\VBeeSettingBundle(),

```

Update the database:

```
php app/console doctrine:schema:update --force

```

Update route for access to the html interface:

```
#app/routing.yml:
v_bee_setting:
    resource: "@VBeeSettingBundle/Resources/config/route/routing.xml"
    prefix:   /setting

v_bee_setting_api:
    resource: "@VBeeSettingBundle/Resources/config/route/api.xml"
    prefix:   /api

```

Import css:

```

```

Install assets:

```
php app/console asset:install

```

Usage in code
=============

[](#usage-in-code)

Create a new Setting

```
$this->container->get('vbee.manager.setting')->create('foo', 'bar'); // default type = 'str'
$this->container->get('vbee.manager.setting')->create('foo', 'bar', 'str');
$this->container->get('vbee.manager.setting')->create('foo', '123', 'int');
// ... check all available types

```

Get a existing Setting

```
$this->container->get('vbee.manager.setting')->get('foo');
// or
$this->container->getParameter('foo');

```

Get all Settings

```
$this->container->get('vbee.manager.setting')->all();

```

Set a new value for a Setting:

```
$this->container->get('vbee.manager.setting')->set('foo', 'bar');
$this->container->get('vbee.manager.setting')->set('foo', 'bar', 'str');
$this->container->get('vbee.manager.setting')->set('foo', '123', 'int');
// ... check all available types

```

Remove a Setting

```
$this->container->get('vbee.manager.setting')->remove('foo');

```

Usage in Twig
=============

[](#usage-in-twig)

Get a existing Setting

```
{{ getSetting('foo') }}

```

Usage in command line
=====================

[](#usage-in-command-line)

Create a new Setting

```
php app/console vbee:setting:create foo bar

```

Remove a Setting

```
php app/console vbee:setting:remove foo bar

```

Purge all Settings

```
php app/console vbee:setting:remove --all

```

Value Types
===========

[](#value-types)

VBeeSetting bundle allow you to make validation on your setting value dynamically.

By Default, these types are available:

TypeIn DBIn CodeStringstr`VBee\SettingBundle\Enum\SettingTypeEnum::STRING`Integerint`VBee\SettingBundle\Enum\SettingTypeEnum::INTEGER`Datedate`VBee\SettingBundle\Enum\SettingTypeEnum::DATE`Phonephone`VBee\SettingBundle\Enum\SettingTypeEnum::PHONE`Urlurl`VBee\SettingBundle\Enum\SettingTypeEnum::URL`Add a Type
==========

[](#add-a-type)

Declare your type
-----------------

[](#declare-your-type)

your first have to declare your new type as:

```
# app/config/config.yml
v_bee_setting:
    types:
        your: { label: setting_type.your }

```

you can use translation file for translate the label

```
# src/Acme/DemoBundle/Resources/translations/VBeeSettingBundle.[locale].yml
setting_type:
    your: "Your"

```

Create your validator
---------------------

[](#create-your-validator)

then you need to make your custom type validator

```
