Download the PHP package kanfa/runner without Composer
On this page you can find all versions of the php package kanfa/runner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package runner
Short Description Run a callback, or an accessible method of a class by giving the parameters if require
License MIT
Homepage https://www.github.com/kanfa/Runner
Informations about the package runner
Runner
Runner is a simple library that run dynamically a callback function, or an accessible method of a class by giving the parameters if require.
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
Callback
Calling a function without parameters
Function with parameters
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
or simply do
You can add objects to inject as default parameters when create runner instance as follow
if you want to use the default configuration
otherwise
this does not work for callback calls
Class Method
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
Use custom class defaults or callback
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. `
Other way to create instance `
Singleton `
We can pass a table instead ini or php file
INI file `
PHP file `