2017 © Pedro Peláez
 

library delay-initializer

A simple delay-initializer library for PHP.

image

litert/delay-initializer

A simple delay-initializer library for PHP.

  • Tuesday, November 7, 2017
  • by litert
  • Repository
  • 1 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 4 % Grown

The README.md

LiteRT/DelayInitializer

Latest Stable Version License, (*1)

A simple delay-initializer and dependency injection library for PHP., (*2)

Installation

It's recommended to install by composer:, (*3)

composer require litert/delay-initializer

Or just git clone this repository, and put the lib directory into you project., (*4)

Samples

Using the delay initializer.

<?php
declare (strict_types = 1);

require 'vendor/autoload.php';

/**
 * @property string $hello
 */
class Tester implements \L\Kits\DelayInit\PropertyContainerEx
{
    use \L\Kits\DelayInit\TPropertyContainerEx;

    public function __construct()
    {
        $this->_initializeDelayInit();

        $this->setInitializer(
            'hello',
            function() {
                echo 'Initialized "hello" here.', PHP_EOL;
                return 'world';
            }
        );
    }
}

$tester = new Tester();

echo 'Now try reading the property "hello" of $tester.', PHP_EOL;

echo $tester->hello, PHP_EOL;

Using the dependency injection container

<?php
declare (strict_types = 1);

require 'vendor/autoload.php';

/**
 * @property string $name
 * @property int $age
 */
class MyDI extends \L\Kits\DelayInit\PropertyDIContainer
{
}

$di = new MyDI();

$di->setInitializer(
    'name',
    function () {
        return 'Mike';
    }
);

$di->setInitializer(
    'age',
    function() {
        return 17;
    }
);

echo "Hi, I'm {$di->name}. I'm {$di->age}.", PHP_EOL;

Would you like to know more?, (*5)

Document

License

This library is published under Apache-2.0 license., (*6)

The Versions

07/11 2017

dev-master

9999999-dev https://fenying.net

A simple delay-initializer library for PHP.

  Sources   Download

Apache-2.0

The Requires

 

delay initializer

07/11 2017

0.3.0

0.3.0.0 https://fenying.net

A simple delay-initializer library for PHP.

  Sources   Download

Apache-2.0

The Requires

 

delay initializer

12/10 2017

0.2.0

0.2.0.0 https://fenying.net

A simple delay-initializer library for PHP.

  Sources   Download

Apache-2.0

The Requires

 

delay initializer

24/08 2017

0.1.2

0.1.2.0 https://fenying.net

A simple delay-initliazer library for PHP.

  Sources   Download

Apache-2.0

The Requires

 

delay initializer

23/08 2017

0.1.1

0.1.1.0 https://fenying.net

A simple delay-initliazer library for PHP.

  Sources   Download

Apache-2.0

The Requires

 

privilege control

20/08 2017

0.1.0

0.1.0.0 https://fenying.net

A simple delay-initliazer library for PHP.

  Sources   Download

Apache-2.0

The Requires

 

privilege control