plinker / core
PlinkerRPC PHP client/server makes it really easy to link and execute PHP component classes on remote systems, while maintaining the feel of a local method call.
Installs: 1 032
Dependents: 12
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- opis/closure: ^3.0.12
Requires (Dev)
- phpunit/phpunit: 4.*
- dev-master
- v3.1.10
- v3.1.9
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.14
- v3.0.13
- v3.0.12
- v3.0.11
- v3.0.10
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.37
- v2.0.36
- v2.0.35
- v2.0.34
- v2.0.33
- v2.0.32
- v2.0.31
- v2.0.30
- v2.0.29
- v2.0.28
- v2.0.27
- v2.0.26
- v2.0.25
- v2.0.24
- v2.0.23
- v2.0.22
- v2.0.21
- v2.0.20
- v2.0.19
- v2.0.18
- v2.0.17
- v2.0.16
- v2.0.15
- v2.0.14
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-version3
- dev-add-license-1
- dev-analysis-Xk4V3A
This package is not auto-updated.
Last update: 2024-11-06 05:40:22 UTC
README
PlinkerRPC PHP client/server makes it really easy to link and execute generic PHP components on remote systems, while maintaining the feel of a local method call.
Docs: https://plinker-rpc.github.io/core
New changes in version 3 include:
- Now compaible with PHP extension.
- Built-in core components and info method added so components can be discovered.
- Only one client instance is now needed, made use of __get() to dynamically set component.
- User defined components/classes, so you can call your own code.
- Both request and response is encrypted and signed.
Install
Require this package with composer using the following command:
$ composer require plinker/core
Additional Setup
This component does not require any additional setup.
Client
Creating a client instance is done as follows:
<?php
require 'vendor/autoload.php';
/**
* Initialize plinker client.
*
* @param string $server - URL to server listener.
* @param string $config - server secret, and/or a additional component data
*/
$client = new \Plinker\Core\Client(
'http://example.com/server.php',
[
'secret' => 'a secret password',
]
);
// or using global function
$client = plinker_client('http://example.com/server.php', 'a secret password');
Server
Creating a server listener is done as follows:
Optional features:
- Set a secret, which all clients will require.
- Lock down to specific client IP addresses for addtional security.
- Define your own classes in the
classes
array then access like above$client->class->method()
, which can interface out of scope components or composer packages. - Define addtional key values for database connections etc, or you could pass the parameters through the client connection.
<?php
require 'vendor/autoload.php';
/**
* Initialize plinker server.
*/
if (isset($_SERVER['HTTP_PLINKER'])) {
// init plinker server
echo (new \Plinker\Server([
'secret' => 'a secret password',
'allowed_ips' => [
'127.0.0.1'
],
'classes' => [
'test' => [
// path to file
'classes/test.php',
// addtional key/values
[
'key' => 'value'
]
],
// you can use namespaced classes
'Foo\\Demo' => [
// path to file
'some_class/demo.php',
// addtional key/values
[
'key' => 'value'
]
],
// ...
]
]))->listen();
}
Methods
Once setup, you call the class though its namespace to its method.
Info
The info method returns defined endpoint methods and their parameters.
Call
$result = $client->info();
Response
Array
(
[class] => Array
(
[Foo\Demo] => Array
(
[config] => Array
(
[key] => value
)
[methods] => Array
(
[config] => Array
(
)
[this] => Array
(
)
[test] => Array
(
[0] => x
[1] => y
)
)
)
)
)
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please contact me via https://cherone.co.uk instead of using the issue tracker.
Credits
Development Encouragement
If you use this code and make money from it and want to show your appreciation, please feel free to make a donation https://www.paypal.me/lcherone, thanks.
Sponsors
Get your company or name listed here.
License
The MIT License (MIT). Please see License File for more information.
See organisations page for additional components.