承接 eventfarm/restforcephp 相关项目开发

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

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

eventfarm/restforcephp

Composer 安装命令:

composer require eventfarm/restforcephp

包简介

PHP Salesforce REST

README 文档

README

Travis Downloads Packagist

This is meant to emulate what the ejhomes/restforce gem is doing for rails.

Installation

This library requires PHP 7.1 or later; we recommend using the latest available version of PHP. It has been test through the latest version of PHP (v8.3 as of this writing)

$ composer require eventfarm/restforcephp

Or.

Add the following lines to your composer.json file.

{
    "require": {
        "eventfarm/restforcephp": "^2.0.0"
    }
}
$ composer install

Project Defaults

<?php
namespace App;

use EventFarm\Restforce\Rest\OAuthAccessToken;
use EventFarm\Restforce\Restforce;
use EventFarm\Restforce\RestforceInterface;

class DemoSalesforceApi
{
    /** @var null|RestforceInterface $restforce */
    private $restforce;

    public function getRestforceClient(): RestforceInterface
    {
        if ($this->restforce === null) {
            // You need either the OAuthAccessToken
            // or the Username & Password,
            // the other(s) can be null.
            $this->restforce = new Restforce(
                getenv('SF_CLIENT_ID'),
                getenv('SF_CLIENT_SECRET'),
                new OAuthAccessToken(...),
                getenv('SF_USERNAME'),
                getenv('SF_PASSWORD')
            );
        }
        return $this->restforce;
    }
}

Access Token Information

OAuth Scopes

Consult the Salesforce OAuth 2.0 Documentation to find out what Available OAuth Scopes your app needs.

Salesforce Documentation

Links to Salesforce documentation pages can be found in each section. Alternatively, here is the holy grail of the Saleforce endpoints.

Usage

Limits

Docs Returns a list of daily API limits for the salesforce api. Refer to the docs for the full list of options.

public function limits(): \Psr\Http\Message\ResponseInterface

<?php
/** @var \EventFarm\Restforce\RestforceInterface $restforce */
$restforce = (new DemoSalesforceApi())->getClient();
/** @var \Psr\Http\Message\ResponseInterface $responseInterface */
$responseInterface = $restforce->limits();

UserInfo

Docs Get info about the logged-in user.

public function limits(): \Psr\Http\Message\ResponseInterface

<?php
/** @var \EventFarm\Restforce\RestforceInterface $restforce */
$restforce = (new DemoSalesforceApi())->getClient();
/** @var \Psr\Http\Message\ResponseInterface $responseInterface */
$responseInterface = $restforce->userInfo();

Query

Docs Use the Query resource to execute a SOQL query that returns all the results in a single response.

public function query(string $query): \Psr\Http\Message\ResponseInterface

<?php
/** @var \EventFarm\Restforce\RestforceInterface $restforce */
$restforce = (new DemoSalesforceApi())->getClient();
/** @var \Psr\Http\Message\ResponseInterface $responseInterface */
$responseInterface = $restforce->query('SELECT Id, Name FROM Account');

Find

Docs Find resource $id of $sobject, optionally specify the fields you want to retrieve in the fields parameter and use the GET method of the resource.

public function find(string $sobject, string $id, array $fields = []): \Psr\Http\Message\ResponseInterface

<?php
/** @var \EventFarm\Restforce\RestforceInterface $restforce */
$restforce = (new DemoSalesforceApi())->getClient();
/** @var \Psr\Http\Message\ResponseInterface $responseInterface */
$responseInterface= $restforce->find('Account', '001410000056Kf0AAE');

Describe

Docs Completely describes the individual metadata at all levels for the specified object.

public function describe(string $sobject): \Psr\Http\Message\ResponseInterface

<?php
/** @var \EventFarm\Restforce\RestforceInterface $restforce */
$restforce = (new DemoSalesforceApi())->getClient();
/** @var \Psr\Http\Message\ResponseInterface $responseInterface */
$responseInterface = $restforce->describe('Account');

Create

Docs Create new records of $sobject. The response body will contain the ID of the created record if the call is successful.

public function create(string $sobject, array $data): \Psr\Http\Message\ResponseInterface

<?php
/** @var \EventFarm\Restforce\RestforceInterface $restforce */
$restforce = (new DemoSalesforceApi())->getClient();
/** @var \Psr\Http\Message\ResponseInterface $responseInterface */
$responseInterface = $restforce->create('Account', [
    'Name' => 'Foo Bar'
]);

Update

Docs You use the SObject Rows resource to update records. The response will be the a bool of $success.

public function update(string $sobject, string $id, array $data):bool

<?php
/** @var \EventFarm\Restforce\RestforceInterface $restforce */
$restforce = (new DemoSalesforceApi())->getClient();
/** @var \Psr\Http\Message\ResponseInterface $responseInterface */
$responseInterface = $restforce->update('Account', '001i000001ysdBGAAY', [
    'Name' => 'Foo Bar Two'
]);

Contributing

Thanks for considering contributing to our Restforcephp project. Just a few things:

  • Make sure your commit conforms to the PSR-2 coding standard.
  • Make sure your commit messages are well defined.
  • Make sure you have added the necessary unit tests for your changes.
  • Run all the tests to assure nothing else was accidentally broken.
  • Submit a pull request.

Unit Tests:

$ vendor/bin/phpunit
With Code Coverage:
$ vendor/bin/phpunit --coverage-text --coverage-html coverage_report

Check PHP-CS PSR2 Test:

$ vendor/bin/phpcs -p --standard=PSR2 src/ tests/

Apply PHP-CS PSR2 Fix:

Auto runs and resolves some low hanging PSR2 fixes, this might not get all of them, so rerun the check after.

$ vendor/bin/phpcbf --standard=PSR2 src/ tests/

Check Compatability for PHP Version:

$ vendor/bin/phpcs -p ./src/ --standard=PHPCompatibility --runtime-set testVersion 7.1-8.4

eventfarm/restforcephp 适用场景与选型建议

eventfarm/restforcephp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 123.12k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2016 年 10 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 23
  • Watchers: 5
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-10