plinker/core
Composer 安装命令:
composer require 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.
README 文档
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
classesarray 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.
plinker/core 适用场景与选型建议
plinker/core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.08k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rpc」 「client」 「server」 「remote」 「plinker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 plinker/core 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 plinker/core 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 plinker/core 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Microservice RPC through message queues.
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
A jQuery augmented PHP library for creating and validating HTML forms
annotations-scan-plugin
统计信息
- 总下载量: 1.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 26
- 依赖项目数: 12
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-06