hvasoares / commons
我在许多项目中使用的通用类
1.0.5
2013-09-03 00:20 UTC
This package is not auto-updated.
Last update: 2024-09-24 04:40:28 UTC
README
介绍
这个仓库是我其他项目中使用的类的集合。最重要的类是Registry。这个类受到马丁·福勒的《企业应用架构模式》一书中展示的概念的启发。其存在的主要原因是依赖注入,我需要一个地方来放置我的依赖,但我没有找到任何好的PHP实现。
要求
- PHP版本 5.3
安装
你可以使用composer,查看项目根目录中的composer文件。只有版本高于1.0.4的版本会被包含在内。
使用示例
$top = new \hvasoares\commons\Registry(); $obj = new stdClass; $top['someObject'] = $obj; $obj == $top['someObject']; //will return true $child = new \hvasoares\commons\Registry($top); $child['someObject'] == $top['someObject']; //will return true $newObj = new stdClass; $child['someObject'] = $newObj; $child['someObject'] == $top['someObject']; //will return false $child['someObject] == $newObj; //will return true