ZF2 Module. Site config module - provide key-value configuration.
Clone this project into your ./vendor/ directory.
- Now tell composer to download SiteConfig by running the command:
$ composer require t4web/site-config:"~2.0.0"- Create tables by initial script:
$ php public/index.php site-config init- Enabling it in your
application.config.phpfile.
<?php
return array(
'modules' => array(
// ...
'T4web\SiteConfig',
),
// ...
);Insert scopes and values to tables site_config_values and site_config_scopes:
INSERT INTO `site_config_scopes` (`id`, `name`)
VALUES (1, 'products');
INSERT INTO `site_config_values` (`id`, `scope_id`, `name`, `value`)
VALUES (1, 1, 'items-per-page', 20);Use it anywhere
$siteConfig = $serviceLocator->get("T4web\SiteConfig\Config");
$siteConfig->get('items-per-page', 'products');
//...
$siteConfig->set('items-per-page', 'products', 10);