, (*1)
Step 1: Download ZentVarsBundle using composer
composer require zent/vars-bundle dev-master
, (*2)
Step 2: Enable the bundle
Enable the bundle in the kernel:, (*3)
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Zent\VarsBundle\ZentVarsBundle(),
// ...
);
}
Step 3: Create your Vars class
// src/AppBundle/Entity/Vars.php
use Zent\VarsBundle\Entity\BaseVars;
class Vars extended BaseVars
{
}
# app/config/config.yml
zent_vars:
class: AppBunde\Entity\Vars
If you need additional caching:, (*4)
doctrine_cache:
providers:
zent_vars_query_cache:
type: apc
namespace: query_cache_ns
alias:
- zent_vars.cache
Doc: https://symfony.com/doc/current/bundles/DoctrineCacheBundle/reference.html, (*5)
Step 5: Update your database schema
Usage
Accessing the User Manager service
$varsManager = $container->get('zent_vars.manager');
$var = $varsManager->getValue('first');
$var = $varsManager->getValue('first', 10); //return '10' if var not found
Twig
{{ vars('first') }}
php app/console zent:vars:create email_owner test@example.com "Email владельца"
php app/console zent:vars:update email_owner test@test.com
php app/console zent:vars:delete email_owner
php app/console zent:vars:list