PHPackages                             tuannguyen/soap-salesforce-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. tuannguyen/soap-salesforce-client

ActiveLibrary

tuannguyen/soap-salesforce-client
=================================

A PHP client for the Salesforce SOAP API

0734PHP

Since May 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tuannguyen-nextgeneration/soap-salesforce-client)[ Packagist](https://packagist.org/packages/tuannguyen/soap-salesforce-client)[ RSS](/packages/tuannguyen-soap-salesforce-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/11d9c1d01786c179f0d00f3fde85dc959825995bfebbf0851f74d04571d66a2d/68747470733a2f2f7472617669732d63692e6f72672f706870666f7263652f736f61702d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpforce/soap-client)
[![Scrutinizer Code Quality](https://camo.githubusercontent.com/35bdd8b794c88fde989b83d401bd856f556389189c60d8006cbfb8145001534c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f706870666f7263652f736f61702d636c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phpforce/soap-client/?branch=master)

\###[I’m looking for maintainers!](https://github.com/phpforce/soap-client/issues/4)

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

[](#phpforce-soap-client-a-php-client-for-the-salesforce-soap-api)

Introduction
------------

[](#introduction)

This library is a client for the [Salesforce SOAP API](http://www.salesforce.com/us/developer/docs/api/index.htm), and intended as a replacement for the [Force.com Tookit for PHP](http://wiki.developerforce.com/page/Force.com_Toolkit_for_PHP).

### Features

[](#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](https://github.com/ddeboer/DdeboerSalesforceMapperBundle)to get even easier access to your Salesforce data.

Installation
------------

[](#installation)

This library is available on [Packagist](http://packagist.org/packages/phpforce/soap-client). The recommended way to install this library is through [Composer](http://getcomposer.org):

```
$ composer require tuannguyen/soap-salesforce-client
```

Usage
-----

[](#usage)

### The client

[](#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

[](#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)

[](#one-to-many-relations-subqueries)

Results from [subqueries](http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select.htm)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

[](#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

[](#logging)

To enable logging for the client, call `withLog()` on the builder. For instance when using [Monolog](https://github.com/Seldaek/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.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1c9db5c0d85564e00a272e88f2c8aa6c0e21708cf241c6331dc71482d0fca7f?d=identicon)[tuannguyen-nextgeneration](/maintainers/tuannguyen-nextgeneration)

---

Top Contributors

[![tuannguyen-nextgeneration](https://avatars.githubusercontent.com/u/133632233?v=4)](https://github.com/tuannguyen-nextgeneration "tuannguyen-nextgeneration (10 commits)")

### Embed Badge

![Health badge](/badges/tuannguyen-soap-salesforce-client/health.svg)

```
[![Health](https://phpackages.com/badges/tuannguyen-soap-salesforce-client/health.svg)](https://phpackages.com/packages/tuannguyen-soap-salesforce-client)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
