定制 phpforce/soap-client 二次开发

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

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

phpforce/soap-client

Composer 安装命令:

composer require phpforce/soap-client

包简介

A PHP client for the Salesforce SOAP API

README 文档

README

Build Status
Scrutinizer Code Quality

###I’m looking for maintainers!

PHPForce Soap Client: a PHP client for the Salesforce SOAP API

Introduction

This library is a client for the Salesforce SOAP API, and intended as a replacement for the Force.com Tookit for PHP.

Features

This library’s features include the following.

  • Automatic conversion between PHP and SOAP date and datetime objects.
  • Automatic conversion of Salesforce (UTC) times to your local timezone.
  • Easily extensible through events: add custom logging, caching, error handling etc.
  • Iterating over large results sets that require multiple calls to the API is easy through the record iterator.
  • The BulkSaver helps you stay within your Salesforce API limits by using bulk creates, deletes, updates and upserts.
  • Completely unit tested (still working on that one).
  • Use the client in conjunction with the Symfony2 Mapper Bundle to get even easier access to your Salesforce data.

Installation

This library is available on Packagist. The recommended way to install this library is through Composer:

$ php composer.phar require phpforce/soap-client dev-master

Usage

The client

Use the client to query and manipulate your organisation’s Salesforce data. First construct a client using the builder:

$builder = new \Phpforce\SoapClient\ClientBuilder(
  '/path/to/your/salesforce/wsdl/sandbox.enterprise.wsdl.xml',
  'username',
  'password',
  'security_token'
);

$client = $builder->build();

SOQL queries

$results = $client->query('select Name, SystemModstamp from Account limit 5');

This will fetch five accounts from Salesforce and return them as a RecordIterator. You can now iterate over the results. The account’s SystemModstamp is returned as a \DateTime object:

foreach ($results as $account) {
    echo 'Last modified: ' . $account->SystemModstamp->format('Y-m-d H:i:') . "\n";
}

One-to-many relations (subqueries)

Results from subqueries are themselves returned as record iterators. So:

$accounts = $client->query(
    'select Id, (select Id, Name from Contacts) from Account limit 10'
);

foreach ($accounts as $account) {
    if (isset($account->Contacts)) {
        foreach ($account->Contacts as $contact) {
            echo sprintf("Contact %s has name %s\n", $contact->Id, $contact->Name);
        }
    }
}

Fetching large numbers of records

If you issue a query that returns over 2000 records, only the first 2000 records will be returned by the Salesforce API. Using the queryLocator, you can then fetch the following results in batches of 2000. The record iterator does this automatically for you:

$accounts = $client->query('Select Name from Account');
echo $accounts->count() . ' accounts returned';
foreach ($accounts as $account) {
    // This will iterate over the 2000 first accounts, then fetch the next 2000
    // and iterate over these, etc. In the end, all your organisations’s accounts
    // will be iterated over.
}

Logging

To enable logging for the client, call withLog() on the builder. For instance when using Monolog:

$log = new \Monolog\Logger('name');  
$log->pushHandler(new \Monolog\Handler\StreamHandler('path/to/your.log'));

$builder = new \Phpforce\SoapClient\ClientBuilder(
  '/path/to/your/salesforce/wsdl/sandbox.enterprise.wsdl.xml',
  'username',
  'password',
  'security_token'
);
$client = $builder->withLog($log)
  ->build();

All requests to the Salesforce API, as well as the responses and any errors that it returns, will now be logged.

phpforce/soap-client 适用场景与选型建议

phpforce/soap-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.94M 次下载、GitHub Stars 达 80, 最近一次更新时间为 2012 年 09 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「salesforce」 「soap」 「crm」 「force.com」 「web services」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 phpforce/soap-client 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.94M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 83
  • 点击次数: 22
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

  • Stars: 80
  • Watchers: 14
  • Forks: 72
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-09-22