2017 © Pedro Peláez
 

library registry

Registry pattern

image

ignaszak/registry

Registry pattern

  • Monday, April 23, 2018
  • by ignaszak
  • Repository
  • 1 Watchers
  • 0 Stars
  • 183 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

ignaszak/registry

Build Status Coverage Status, (*1)

Registry pattern, (*2)

Installing

The package is avilable via Composer/Packagist, so just add following lines to your composer.json file:, (*3)

"require" : {
    "ignaszak/registry" : "*"
}

or:, (*4)

composer require ignaszak/registry

Running Tests

Just run phpunit from the working directory, (*5)

phpunit

Requirments

php >= 7.0, (*6)

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');

The Versions

23/04 2018

dev-master

9999999-dev

Registry pattern

  Sources   Download

MIT

The Requires

 

by Tomasz Ignaszak

pattern registry

04/05 2016

v1.1.1

1.1.1.0

Registry pattern

  Sources   Download

MIT

The Requires

 

by Tomasz Ignaszak

pattern registry

18/03 2016

v1.1.0

1.1.0.0

Registry pattern

  Sources   Download

MIT

The Requires

 

by Tomasz Ignaszak

pattern registry

12/12 2015

v1.0.0

1.0.0.0

Registry pattern

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Tomasz Ignaszak

pattern registry