定制 syniah/onecrmclient 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

syniah/onecrmclient

Composer 安装命令:

composer require syniah/onecrmclient

包简介

Client wrapper for the 1CRM REST service

README 文档

README

1CRM is a powerful open-source CRM system originally derived from SugarCRM, and it retains compatibility with its legacy REST API. This class provides a wrapper to make connecting and calling API methods easier, faster, safer, and more efficient. SugarCRM provides its own PHP client class that will work when talking to SugarCRM or 1CRM, however, it's poorly designed, outdated and inefficient, so I wrote this class as a better alternative.

1CRM supports the SugarCRM v4 REST API, not the newer v10 API. Prior to v10, SugarCRM's REST interface is a misnomer; there's nothing REST-like about it. It's simply a wrapper around the SOAP API that supports JSON instead of XML for requests and responses, so don't expect to be able to use POST/PUT/GET/DELETE HTTP verbs!

Because of this, the best way to discover available functions and parameters is to browse the SOAP WSDL available at /soap.php in your 1CRM installation. All the functions and parameters are described there and may be passed to the call function as appropriate.

The class is compatible with TLS (which you should be using anyway!), HTTP/2, SPDY, IPv4 and IPv6, and makes use of HTTP compression and keep-alive for greatest efficiency. Certificate verification is enabled, so you will get errors if you try to use a self-signed, invalid, or expired TLS certificate.

Requirements

The class requires that you are running PHP 5.4 or later, and have the PHP curl extension enabled. If you are serving your site over HTTP/2, and have a recent enough CURL library with nghttp2 support compiled into PHP, this client will use HTTP/2.

Usage

This class is available in composer via packagist; either run composer require syniah/onecrmclient "~1.0" or add this line to your composer.json file manually, then run composer update:

"syniah/onecrmclient": "~1.0"

The class is structured according to the PSR-4 convention, uses the PSR-2 coding standard, is compatible with PHP 5.4 and later, and uses the OneCRM namespace.

<?php
require 'vendor/autoload.php';

$c = new OneCRM\Client('https://1crm.example.com/service/v4/rest.php', false);
try {
    $c->login('demo', 'demo');
    echo $c->listModules();
    //Find the first 10 accounts
    $response = $c->call(
        'Accounts',
        'get_entry_list',
        array('select_fields' => array('id', 'name'), 'max_results' => 10)
    );
    foreach ($response->entry_list as $item) {
        foreach ($item->name_value_list as $field) {
            echo $field->name, ': ', $field->value . " ";
        }
        echo "\n";
    }
} catch (OneCRM\Exception $e) {
    echo 'An error occurred: '. get_class($e) . ': ' . $e->getMessage();
}

Debugging

There is a built-in debug facility that outputs events, data structures and timings to STDERR - just pass true as the second parameter to the constructor: $c = new Client($url, true);. Because this goes to STDERR, this will not usually appear if you're running via a web server, but will appear in your server's error log; debug output will be visible if you're running via a CLI.

Alternatively you can inject your own debug facility by passing in a callable that accepts a single parameter containing the debug item (which may not be a string), which you can then handle as you like, for example:

$c = new OneCRM\Client($endpoint, function ($msg) {
    echo var_export($msg, true) . "\n";
});

Contributing

Please submit any bug reports or pull requests to the GitHub project.

Author

This class was written by Marcus Bointon of Synchromedia Limited. Synchromedia has been a UK partner for 1CRM since 2006.

License

This code is distributed under the MIT open-source license; see the LICENSE file for details.

syniah/onecrmclient 适用场景与选型建议

syniah/onecrmclient 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 syniah/onecrmclient 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 syniah/onecrmclient 我们能提供哪些服务?
定制开发 / 二次开发

基于 syniah/onecrmclient 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-30