Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/baraja-core/service-method-invoker
Invoke method by service, name and arguments.
https://github.com/baraja-core/service-method-invoker
invoke invoker method php
Last synced: about 2 months ago
JSON representation
Invoke method by service, name and arguments.
- Host: GitHub
- URL: https://github.com/baraja-core/service-method-invoker
- Owner: baraja-core
- License: mit
- Created: 2020-04-23T09:44:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-07T11:24:30.000Z (over 2 years ago)
- Last Synced: 2024-09-22T12:05:39.251Z (3 months ago)
- Topics: invoke, invoker, method, php
- Language: PHP
- Homepage: https://php.baraja.cz
- Size: 173 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP method safe invoke
======================![Integrity check](https://github.com/baraja-core/service-method-invoker/workflows/Integrity%20check/badge.svg)
Imagine you have instance of your custom service and you want invoke some action method with sets of parameters.
This package is simply way how to invoke all your methods.
π¦ Installation & Basic Usage
-----------------------------This package can be installed using [Package Manager](https://github.com/baraja-core/package-manager) which is also part of the Baraja [Sandbox](https://github.com/baraja-core/sandbox). If you are not using it, you will have to install the package manually using this guide.
*No package configuration is required. Simply create an instance and the class is ready to use immediately.*
To manually install the package call Composer and execute the following command:
```shell
$ composer require baraja-core/service-method-invoker
```πΊοΈ Simple example
-----------------Think of a simple service as an API endpoint with a public method for hydrating your data:
```php
$invoker = new \Baraja\ServiceMethodInvoker;
$apiEndpoint = new \Baraja\MyApiEndpoint;$data = $invoker->invoke($apiEndpoint, 'actionDetail', ['id' => 42]);
var_dump($data); // return "My id is: 42"
```And your endpoint can be:
```php
class MyApiEndpoint
{
public function actionDetail(int $id): string
{
return 'My id is: ' . $id;
}
}
```π License
-----------`baraja-core/service-method-invoker` is licensed under the MIT license. See the [LICENSE](https://github.com/baraja-core/service-method-invoker/blob/master/LICENSE) file for more details.