承接 ehaerer/php-salesforce-rest-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ehaerer/php-salesforce-rest-api

Composer 安装命令:

composer require ehaerer/php-salesforce-rest-api

包简介

PHP Salesforce REST API wrapper

README 文档

README

-- 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

Install

Via Packagist with composer:

composer require ehaerer/php-salesforce-rest-api

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

Example

See a full example which could be tested with ddev local in /example folder folder.

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 = 'SELECT Id,Name FROM ACCOUNT LIMIT 100';

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

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

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

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

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

Upsert

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

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

Delete

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

Describe

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

Custom endpoint

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

Changelog:

21.05.2026
  • raised PHP version to minimum version >= 8.2
  • updated ddev to latest version
  • updated example code
  • code cleanup
  • set default Salesforce API to v61.0 (Summer '24)
29.03.2022
06.05.2021
  • [breaking] switched version parameter in constructor to the end
01.03.2021
  • added method to use custom endpoints
08.09.2020
  • added describe method
18.01.2020
  • switched to PHP >7.0
  • renamed class from CRUD to SalesforceFunctions
  • added dependency to ext-json in composer package

ehaerer/php-salesforce-rest-api 适用场景与选型建议

ehaerer/php-salesforce-rest-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 96.98k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2020 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 ehaerer/php-salesforce-rest-api 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 96.98k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 66
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-18