cti/saprfc
Composer 安装命令:
composer require cti/saprfc
包简介
Saprfc abstraction layer
README 文档
README
This component is wrapper for native saprfc extension (saprfc.sourceforge.net).
Function module reverse-engeneering and providing only one method to do all tasks.
You can write your code using GatewayInterface and then use proxy or direct connection.
Installation
Using composer.
{
"require": {
"cti/saprfc": "*"
}
}
Basic usage
Server has saprfc extension and can connect to SAP R/3 (same network).
<?php use Cti\SapRfc\Gateway; // params for saprfc_open // http://saprfc.sourceforge.net/src/saprfc.html#function.saprfc-open.html $connectionParams = array( 'USER' => 'USERNAME', 'PASSWD' => 'PASSWORD', // ... ); $sap = new Gateway($connectionParams); $request = array( // use import params 'I_ID_USER' => 12345, 'I_LIMIT' => 50, 'I_OFFSET' => 25, // fill tables 'IT_FILTER' => array( array('FIELD' => 'STATUS', 'VALUE' => 'ACTIVE') ) ); $response = array( // use export params 'TOTAL_CNT', 'LAST_UPDATE', // use table result 'IT_RECIPE_LIST' ); $result = $sap->execute('Z_GET_RECIPE_LIST', $request, $response); // $result contains properties TOTAL_CNT, LAST_UPDATE, IT_RECIPE_LIST. // TOTAL_CNT and LAST_UPDATE are scalar values // IT_RECIPE_LIST is array of data // echo $result->TOTAL_CNT; foreach($result->IT_RECIPE_LIST as $recipe) { echo $recipe->ID_RECIPE, ' ', $recipe->name, '<br/>'; }
Proxy usage
Sap rfc library can be used in proxy mode. For example:
- first server is in intranet and it can connect to Sap R/3
- second server has vpn connection to first server and has no saprfc extension
First server proxy.php file:
<?php use Cti\SapRfc\Gateway; use Cti\SapRfc\Proxy; // params for saprfc_open // http://saprfc.sourceforge.net/src/saprfc.html#function.saprfc-open.html $connectionParams = array( 'USER' => 'USERNAME', 'PASSWD' => 'PASSWORD', // ... ); $sap = new Gateway($connectionParams); $proxy = new Proxy(); $proxy->processRequest($sap);
Second server request.php file:
<?php use Cti\SapRfc\Proxy; $request = array( // use import params 'I_ID_USER' => 12345, 'I_LIMIT' => 50, 'I_OFFSET' => 25, // fill tables 'IT_FILTER' => array( array('FIELD' => 'STATUS', 'VALUE' => 'ACTIVE') ) ); $response = array( // use export params 'TOTAL_CNT', 'LAST_UPDATE', // use table result 'IT_RECIPE_LIST' ); $proxy = new Proxy(); $proxy->setUrl("http://intranet_server_url/proxy.php"); $result = $proxy->execute('Z_GET_RECIPE_LIST', $request, $response); // $result contains properties TOTAL_CNT, LAST_UPDATE, IT_RECIPE_LIST. // TOTAL_CNT and LAST_UPDATE are scalar values // IT_RECIPE_LIST is array of data // echo $result->TOTAL_CNT; foreach($result->IT_RECIPE_LIST as $recipe) { echo $recipe->ID_RECIPE, ' ', $recipe->name, '<br/>'; }
Profiling your requests
Gateway interface provides profiler injection.
With this object you can analyze your call, time and memory usage.
<?php use Cti\SapRfc\Gateway; use Cti\SapRfc\Profiler; // params for saprfc_open // http://saprfc.sourceforge.net/src/saprfc.html#function.saprfc-open.html $connectionParams = array( 'USER' => 'USERNAME', 'PASSWD' => 'PASSWORD', // ... ); $sap = new Gateway($connectionParams); $sap->setProfiler(new Profiler()); $name = 'FUNCTIONAL_MODULE_NAME'; $request = array( // ... ); $response = array( // ... ); $result = $sap->execute($name, $request, $response); foreach($sap->getProfiler()->getData() as $transaction) { echo $transaction->name; var_dump($transaction->request); if($transaction->success) { var_dump($transaction->response); } else { echo 'FAIL: ', $transaction->message; } echo $transaction->time, ' seconds' ; }
cti/saprfc 适用场景与选型建议
cti/saprfc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 533 次下载、GitHub Stars 达 2, 最近一次更新时间为 2014 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cti/saprfc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cti/saprfc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 533
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2014-04-09