2017 © Pedro Peláez
 

library runner

Run a callback, or an accessible method of a class by giving the parameters if require

image

kanfa/runner

Run a callback, or an accessible method of a class by giving the parameters if require

  • Thursday, April 26, 2018
  • by bstylene
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Runner Build Status

Runner is a simple library that run dynamically a callback function, or an accessible method of a class by giving the parameters if require., (*1)

How to use

It creates an array with the following keys: - "callback" to indicate a callback function - "class" to indicate the name of a class - "action" to indicate the name of a method belonging to the instance of the class name indicate as the value for the key "class" - "params" to indicate the parameters to call, (*2)

Callback, (*3)

Calling a function without parameters, (*4)

$parameters = [];
$parameters['callback'] = function () {
    echo 'Function Body';
};
$runner = new \Runner\Engine\Runner($parameters);
$runner->run();

Function with parameters, (*5)

$parameters = [];
$parameters['callback'] = function ($foo) {
    echo 'Function Body';
};
$parameters['params'] = ['foo']

To run, just do it, you have of course in the case of a callback function with the number of parameters given to this function is equal to the number of parameters in the table indexed by key 'params', otherwise throw exception, (*6)

$runner = new \Runner\Engine\Runner();
$runner->run($params);

or simply do, (*7)

Runner\Engine\Runner::invokeRun($params);

You can add objects to inject as default parameters when create runner instance as follow, (*8)

if you want to use the default configuration sh $runner = Runner\Engine\Runner::createForm(new Class\To\Inject()); otherwise sh $runner = Runner\Engine\Runner::create('path/to/ini_or_php/file', new Class\To\Inject()); this does not work for callback calls, (*9)

Class Method, (*10)

Same as above, except that instead of a given function of recalls, we give a class name and a method name, if the method exists, it will be called if an exception is thrown, (*11)

$parameters = [];
$parameters['class'] = '\ClassNamespace\FakeClass'
$parameters['action']) = 'find';
$parameters['params'] = ['id']


Use custom class defaults or callback, (*12)

You specifies the value (class or callback methods previously created) of the keys defaults_r or callback_r in a INI file, after the file path is given as the second constructor parameter to the Runner class. ```sh $runner = new \Runner\Engine\Runner(path/to/ini_or_php/file);, (*13)


_Other way to create instance_ ```sh $runner = \Runner\Engine\Runner::create(path/to/ini_or_php/file);

Singleton ```sh $runner = \Runner\Engine\Runner::singleton(path/to/ini_or_php/file);, (*14)


We can pass a table instead ini or php file **INI file** ```sh default_r = \Custom\DefaultsRunner\FakeClass callback_r = \Custom\CallbackRunner\FakeClass

PHP file ```sh <?php, (*15)

return [ 'default_r' => '\Custom\DefaultsRunner\FakeClass' 'callback_r' => '\Custom\CallbackRunner\FakeClass' ]; ````, (*16)

The Versions

26/04 2018

dev-master

9999999-dev https://www.github.com/kanfa/Runner

Run a callback, or an accessible method of a class by giving the parameters if require

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Ibrahim Maiga

run call runner

26/04 2018

dev-develop

dev-develop https://www.github.com/kanfa/Runner

Run a callback, or an accessible method of a class by giving the parameters if require

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Ibrahim Maiga

run call runner

26/04 2018

v1.0.x-dev

1.0.9999999.9999999-dev https://www.github.com/kanfa/Runner

Run a callback, or an accessible method of a class by giving the parameters if require

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Ibrahim Maiga

run call runner

26/04 2018

v1.0

1.0.0.0 https://www.github.com/kanfa/Runner

Run a callback, or an accessible method of a class by giving the parameters if require

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Ibrahim Maiga

run call runner