poznet/configbundle

SF2中的简单配置处理

v1.2.2 2019-11-02 19:21 UTC

This package is auto-updated.

Last update: 2024-08-29 03:58:12 UTC


README

SF中的简单配置处理

SensioLabsInsight

想法

想法非常简单,在使用symfony时,你经常需要保存一些配置数据。Parameters.yml 是好的,但从应用程序级别保存项目到它们是有问题的。

所以基于WP/Presta的经验,我创建了一个简单的服务来存储一些数据。

数据被序列化并存储在数据库中。

安装

使用 composer require poznet/ConfigBundle

使用方法

简单

$this->get('configuration')->set('foo','bar'); - 将 'bar' 字符串保存到键为 'foo' 的配置中。你也可以保存任何类型的数据(变量、类等。)

要检索数据,使用

$x=$this->get('configuration')->get('foo');

保存多对象配置的使用

$this->get('configuration')->setFor('foo','objectName','bar');

要检索对象的数据,使用

$x=$this->get('configuration')->get('foo','objectName');

许可证

此包采用MIT许可证。请随意贡献。