Download the PHP package eye4web/zf2-site-config without Composer
On this page you can find all versions of the php package eye4web/zf2-site-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eye4web/zf2-site-config
More information about eye4web/zf2-site-config
Files in eye4web/zf2-site-config
Package zf2-site-config
Short Description Site-configuration module for Zend Framework 2
License MIT
Homepage https://github.com/Eye4web/ZF2-Site-Config
Informations about the package zf2-site-config
Eye4web\SiteConfig
Introduction
This modules allows you to easily get site config in all of your files. The module can, out-of-the-box, read config values from the following:
- DoctrineORM
- Files(supported by
\Zend\Config\Reader
)- ini
- json
- xml
- yaml
- javaproperties
- php array
Note: This module does not help you write the config, you have to take care of that yourself.
Installation
-
Run the followng composer command:
-
Enable it in your
application.config.php
file. -
Copy
config/eye4web.siteconfig.global.php.dist
toconfig/autoload/eye4web.siteconfig.global.php
- Edit the config to fit your needs
Usage
It is very easy to get config values, anywhere in your files.
View
To get a config value in a view-file(or layout): $this->siteConfig($configKey, $default)
$default
is optional
Controller
To get a config value in a controller: $this->siteConfig($configKey, $default)
$default
is optional
Any file from service-manager
This module comes with an initializer, so to get the SiteConfigService
into a file, all you have to do is
- Make your file implement
Eye4web\SiteConfig\Service\SiteConfigAwareInterface
-
Use the trait
Eye4web\SiteConfig\Service\SiteConfigAwareTrait
- Now you can do
$this->getSiteConfigService()->get($configKey, $default)
,$default
is optional
Configuration
See config/eye4web.siteconfig.global.php.dist
for configurable values
Readers
The modules supports many different readers, by deault it uses DoctrineORMReader
DoctrineORM
This reader reads config values from your database. This module is setup to use DoctrineORM by default, so all you have to do is
- Create schema
- Use the doctrine script:
php ./vendor/bin/doctrine-module orm:schema-tool:update --force
or - Create the table yourself, see
data/sql
folder for schema
- Use the doctrine script:
- Add your config values to the database. You only have to fill
key
andvalue
, the rest of the fields are just convenience fields
Files
This module uses Zend\Config
to read config from files. It can read config from the following file types:
- ini
- json
- xml
- yaml
- javaproperties
- php array
To read config from a file, all you have to do is:
- Create your file and add your config values
- Edit
eye4web.siteconfig.global.php
and set the path to your config file
You can read config from a single file, but you can also read from multiple files, just use an array of file names instead of a single string
Create-your-own
It is very easy to create your own reader, just follow these steps:
- Create your reader. It must implement
Eye4web\SiteConfig\Reader\ReaderInterface
- Add your reader to the service-manager
- Edit
eye4web.siteconfig.global.php
and set the name of your reader - Make a pull-request so others can benefit from your reader ;)
All versions of zf2-site-config with dependencies
zendframework/zend-config Version ~2.3|~3.0
zendframework/zend-servicemanager Version ~2.3|~3.0
ocramius/proxy-manager Version ~1.0|~2.0