ignaszak/registry
Composer 安装命令:
composer require ignaszak/registry
包简介
Registry pattern
关键字:
README 文档
README
Registry pattern
Installing
The package is avilable via Composer/Packagist, so just add following lines to your composer.json file:
"require" : { "ignaszak/registry" : "*" }
or:
composer require ignaszak/registry
Running Tests
Just run phpunit from the working directory
phpunit
Requirments
php >= 7.0
Example
use Ignaszak\Registry\Conf; use Ignaszak\Registry\RegistryFactory; include __DIR__ . '/autoload.php'; // Configuration - optional // Conf::setTmpPath(string $tmpPath); // default: './src/tmp' // Conf::setCookieLife(int $cookieLife); // default: 30 days // Conf::setCookiePath(string $cookiePath) // default: '/' // Use start method to begin // RegistryFactory::start([string $registry = 'request']): // 'request' - stores objects in variable - DEFAULT OPTION // 'session' - stores objects in session // 'cookie' - stores objects in cookie // 'file' - stores objects in files $registry = RegistryFactory::start(); // Use set and get methods // The first parameter is a key at witch created object is stored // Key is used in any other method $registry->set('key', new AnyClass); $registry->get('key'); // Returns AnyClass instance // Returns true if the key is defined $registry->has('key'); // Reload object $registry->reload('key'); // Removes from register $registry->remove('key'); // Use register method // First use sets and returns instance of Namespace\AnyClass // Any further use only returns instance of Namespace\AnyClass $registry->register('Namespace\AnyClass'); // It is possible to use has, reload and remove methods $registry->has('Namespace\AnyClass'); $registry->reload('Namespace\AnyClass'); $registry->remove('Namespace\AnyClass');
统计信息
- 总下载量: 191
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-06