chathura86/zf2-application-variable

提供应用级变量的 Zend Framework 2 模块

dev-master 2014-04-22 18:55 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:54:48 UTC


README

Zend 2 的应用级变量

(这是一个定制版本,目前还不适合通用。一旦适合通用,我会更新它。不过,如果你知道自己在做什么,可以自由使用它。)

需求

安装

  1. 在你的 composer.json 中添加
{
    "require": {
        "chathura86/zf2-application-variable": "dev-master"
    }
}
  1. 运行 php composer.phar install
  2. 打开 configs/application.config.php 并将 'AppVariableBundle' 添加到你的 'modules' 参数中。

如何设置

<?php
// configs/autoload/local.php
return array(
	// other configurations
    'AppVariableBundle' => array(
        'driver' => 'memory',			// available drivers memory|file
		'path' => sys_get_temp_dir()	// requred only for file based driver
    )
);
?>

如何使用

// in controller
$this->getServiceLocator()->get('AppVariable') // VariableManager object