PHPackages                             ehaerer/php-salesforce-rest-api - 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. [API Development](/categories/api)
4. /
5. ehaerer/php-salesforce-rest-api

ActiveLibrary[API Development](/categories/api)

ehaerer/php-salesforce-rest-api
===============================

PHP Salesforce REST API wrapper

1.2.0(10mo ago)780.3k—0.2%7MITPHPPHP &gt;=8.0

Since May 29Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/Kephson/php-salesforce-rest-api)[ Packagist](https://packagist.org/packages/ehaerer/php-salesforce-rest-api)[ RSS](/packages/ehaerer-php-salesforce-rest-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (17)Used By (0)

PHP Salesforce REST API wrapper
===============================

[](#php-salesforce-rest-api-wrapper)

\-- Small and easy to use --

Forked from: `bjsmasth/php-salesforce-rest-api` `Cleeng/php-salesforce-rest-api` `jerkob/php-salesforce-rest-api-forked`

Similar packages
----------------

[](#similar-packages)

- SOQL with Doctrine DBAL:
- Interacting with Salesforce objects:

Install
-------

[](#install)

Via [Packagist](https://packagist.org/packages/ehaerer/php-salesforce-rest-api) with **[composer](https://getcomposer.org/)**:

```
composer require ehaerer/php-salesforce-rest-api
```

Getting Started
===============

[](#getting-started)

Setting up a Connected App

1. Log into your Salesforce org
2. Click on Setup in the upper right-hand menu
3. Under Build click `Create > Apps `
4. Scroll to the bottom and click `New` under Connected Apps.
5. Enter the following details for the remote application:
    - Connected App Name
    - API Name
    - Contact Email
    - Enable OAuth Settings under the API dropdown
    - Callback URL
    - Select access scope (If you need a refresh token, specify it here)
6. Click Save

After saving, you will now be given a *consumer key* and *consumer secret*. Update your config file with values for `consumerKey` and `consumerSecret`

Setup
=====

[](#setup)

### Example

[](#example)

See a full example which could be tested with [ddev local](https://github.com/drud/ddev/) in [/example folder](example/) folder.

### Authentication

[](#authentication)

```
    $options = [
        'grant_type' => 'password',
        'client_id' => 'CONSUMERKEY', /* insert consumer key here */
        'client_secret' => 'CONSUMERSECRET', /* insert consumer secret here */
        'username' => 'SALESFORCE_USERNAME', /* insert Salesforce username here */
        'password' => 'SALESFORCE_PASSWORD' . 'SECURITY_TOKEN' /* insert Salesforce user password and security token here */
    ];

    $salesforce = new \EHAERER\Salesforce\Authentication\PasswordAuthentication($options);
    /* if you want to login to a Sandbox change the url to https://test.salesforce.com/ */
    $endPoint = 'https://login.salesforce.com/';
    $salesforce->setEndpoint($endPoint);
    $salesforce->authenticate();

    /* if you need access token or instance url */
    $accessToken = $salesforce->getAccessToken();
    $instanceUrl = $salesforce->getInstanceUrl();

    /* create salesforceFunctions object with instance, accesstoken and API version */
    $salesforceFunctions = new \EHAERER\Salesforce\SalesforceFunctions($instanceUrl, $accessToken, "v52.0");
```

#### Query

[](#query)

```
    $query = 'SELECT Id,Name FROM ACCOUNT LIMIT 100';

    $additionalHeaders = ['key' => 'value'];

    /* returns array with the queried data */
    $data = $salesforceFunctions->query($query, $additionalHeaders);
```

#### Create

[](#create)

```
    $data = [
       'Name' => 'Some name',
    ];
    $additionalHeaders = ['key' => 'value'];

    /* returns the id of the created object or full response */
    $accountId = $salesforceFunctions->create('Account', $data, $additionalHeaders);
    $fullResponse = $salesforceFunctions->create('Account', $data, $additionalHeaders, true);
```

#### Update

[](#update)

```
    $newData = [
       'Name' => 'another name',
    ];
    $additionalHeaders = ['key' => 'value'];

    /* returns statuscode */
    $salesforceFunctions->update('Account', $id, $newData, $additionalHeaders);
```

#### Upsert

[](#upsert)

```
    $newData = [
       'Name' => 'another name',
    ];
    $additionalHeaders = ['key' => 'value'];

    /* returns statuscode */
    $salesforceFunctions->upsert('Account', 'API Name/ Field Name', 'value', $newData, $additionalHeaders);
```

#### Delete

[](#delete)

```
    $additionalHeaders = ['key' => 'value'];
    $salesforceFunctions->delete('Account', $id, $additionalHeaders);
```

#### Describe

[](#describe)

```
    $additionalHeaders = ['key' => 'value'];
    $salesforceFunctions->describe('Account', $additionalHeaders);
```

#### Custom endpoint

[](#custom-endpoint)

```
    $additionalHeaders = ['key' => 'value'];
    $salesforceFunctions->customEndpoint('apex/myCustomEndpoint', $data, 200, $additionalHeaders);
```

#### Changelog:

[](#changelog)

##### 29.03.2022

[](#29032022)

- updated Guzzle dependency to ^7.4
- added full example in /example folder with ddev local configuration
- added option to add additional headers like on [https://developer.salesforce.com/docs/atlas.en-us.api\_rest.meta/api\_rest/headers.htm](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers.htm)
- updated documentation

##### 06.05.2021

[](#06052021)

- \[breaking\] switched version parameter in constructor to the end

##### 01.03.2021

[](#01032021)

- added method to use custom endpoints

##### 08.09.2020

[](#08092020)

- added describe method

##### 18.01.2020

[](#18012020)

- switched to PHP &gt;7.0
- renamed class from CRUD to SalesforceFunctions
- added dependency to ext-json in composer package

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance55

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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.

###  Release Activity

Cadence

Every ~198 days

Recently: every ~302 days

Total

16

Last Release

300d ago

Major Versions

v0.4 → 1.0.02020-01-18

PHP version history (4 changes)v0.1PHP &gt;=5.5

1.0.0PHP &gt;=7.0

1.1.1PHP &gt;=7.4

1.2.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2724872?v=4)[Ephraim Härer](/maintainers/Kephson)[@Kephson](https://github.com/Kephson)

---

Top Contributors

[![bjsmasth](https://avatars.githubusercontent.com/u/5401401?v=4)](https://github.com/bjsmasth "bjsmasth (15 commits)")[![jerkob](https://avatars.githubusercontent.com/u/523301?v=4)](https://github.com/jerkob "jerkob (15 commits)")[![Kephson](https://avatars.githubusercontent.com/u/2724872?v=4)](https://github.com/Kephson "Kephson (10 commits)")[![rodrigoaguilera](https://avatars.githubusercontent.com/u/655187?v=4)](https://github.com/rodrigoaguilera "rodrigoaguilera (2 commits)")[![kwiercioch](https://avatars.githubusercontent.com/u/5021386?v=4)](https://github.com/kwiercioch "kwiercioch (2 commits)")[![BaderSZ](https://avatars.githubusercontent.com/u/2165320?v=4)](https://github.com/BaderSZ "BaderSZ (2 commits)")[![mtymek](https://avatars.githubusercontent.com/u/777893?v=4)](https://github.com/mtymek "mtymek (2 commits)")[![nachitox](https://avatars.githubusercontent.com/u/1167303?v=4)](https://github.com/nachitox "nachitox (2 commits)")[![laszlof](https://avatars.githubusercontent.com/u/1486486?v=4)](https://github.com/laszlof "laszlof (1 commits)")

---

Tags

php salesforcephp salesforce restphp salesforce rest api

### Embed Badge

![Health badge](/badges/ehaerer-php-salesforce-rest-api/health.svg)

```
[![Health](https://phpackages.com/badges/ehaerer-php-salesforce-rest-api/health.svg)](https://phpackages.com/packages/ehaerer-php-salesforce-rest-api)
```

###  Alternatives

[bjsmasth/php-salesforce-rest-api

55112.7k](/packages/bjsmasth-php-salesforce-rest-api)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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