uuf6429/force.com-toolkit-for-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

uuf6429/force.com-toolkit-for-php

Composer 安装命令:

composer require uuf6429/force.com-toolkit-for-php

包简介

A wrapper for the Force.com Web Services SOAP API

README 文档

README

Build Status Minimum PHP Version License Coverage Packagist

The Force.com PHP Toolkit provides an easy-to-use wrapper for the Force.com Web Services SOAP API, presenting SOAP client implementations for both the enterprise and partner WSDLs.

See the getting started guide for sample code to create, retrieve, update and delete records in the Force.com database.

Upgrade

This newer version of the library is a major rewrite.

Migration should not be dificult since the public interface stayed the same or changed slightly (eg; some global constants are now class constants).

Here's an overview of what changed:

  • More Composer: Requirements such as PHP extensions and 3rd-party PHP packages are now served through composer. This means once you install your extension with Composer, you won't have any further dependencies issues.
  • Namespacing: Everything is now under SForce namespace. In particular this solves issues were very generic class names caused conflicts.
  • Cleaner Global Scope: Since everything was moved to the namespace, things like constants or variables have also moved.
  • PSR-2: Updated coding standard, also increases code quality. In particular, every class has its own file now.
  • Better Dev Env: Contributing has become even easier. Code style is fixed automatically, running tests is easier, continuous test runs etc.
  • Bug Fixes: Huge amount of bugs have been fixed: whitespace in output from some files, missing variables, redundant arguments, incorrect method calls etc...
  • Schema Generator: A tool for generating a rough DDL schema which you can use in your IDE to help writing SOQL queries.
  • Badges: Now you can quickly get an overview of the project just by looking at the summary.
  • Custom API Version: You can use your own WSDL sources, which means you can use a different API version, potentially with access to more API entities.

These changes come at a cost. The minimum supported PHP version is PHP 5.6. It might work with older versions, but no guarantees. You should upgrade immediately if you are still using an unsupported PHP version.

Installation

The easist way to include this library in your project is to use Composer:

composer require uuf6429/Force.com-Toolkit-for-PHP

Alternatively, the library can be loaded by any PSR-4 autoloader.

Important: This library generates classes from WSDL inside src/SForce/Wsdl by default. Please see WSDL Class Path section to change this behaviour.

Features

WSDL Sources

The WSDL can be customized for your desired version and source. You can either provide your own WSDL file(s) or having your own code providing these.

Note: This library relies on one specific WSDL source, so for example, you cannot connect to two (or more) API endpoints with different WSDL sources. In this case, pick a common API level and use it for all.

To use your own WSDL source, first you have to add an "extras" entry to your composer.json and then you need to pass the correct WSDL path to $client->createConnection($wsdl). Here are a few composer.json examples:

  • A class with a static method that returns a list of sources (as strings)
    {
        "extra": {
            "sforce-wsdl-source": "MyWsdlSource::getSource"
        }
    }
  • A function that returns a list of sources (as strings)
    {
        "extra": {
            "sforce-wsdl-source": "myproject_get_wsdl_source"
        }
    }
  • A list of URLs (must be accessible by composer)
    {
        "extra": {
            "sforce-wsdl-source": [
                "https://my-sforce.com/soap/enterprise.wsdl",
                "https://my-sforce.com/soap/partner.wsdl",
                "https://my-sforce.com/soap/metadata.wsdl"
            ]
        }
    }
  • A list of local files (relative to project root)
    {
        "extra": {
            "sforce-wsdl-source": [
                "src/SForce/Wsdl/enterprise.wsdl",
                "src/SForce/Wsdl/partner.wsdl",
                "src/SForce/Wsdl/metadata.wsdl"
            ]
        }
    }

WSDL Class Path

As mentioned in the previous section, some classes are generated from the SOAP WSDL, even if the default settings are used. By default, these classes will end up in src/SForce/Wsdl of your project, however this can be changed via composer.json:

{
    "extra": {
        "sforce-wsdl-classpath": "cache/SForce"
    }
}
  • Note 1: The autoloader is automatically updated to point to the class path. You don't need to change it yourself. In other words: class are loaded automatically.
  • Note 2: Every time you change the location, make sure to delete the generated files from the previous location. The generator cannot clean up for you since it won't know about the previous location.

Schema Generator

The SchemaGen class is a simple tool that generates a rough DDL for the SOAP API. You can use the generated SQL schema file inside your IDE as a "DDL Data Source" (eg, in PhpStorm). This allows the IDE to suggest useful information when you're writing your SOQL queries. Here's how it looks like:

SchemaGen

Testing

Unit tests only require PHPUnit (installed by default via Composer), so you can simply run the following:

vendor/bin/phpunit test/Unit

Integration tests require a real SalesForce account and you need to provide the credentials as environment variables:

SALESFORCE_USER="john@doe.com"
SALESFORCE_PASS="Som3p4ssw0rd"
SALESFORCE_TOKEN="b0dca2fa0b3ef1a5bf5ba9dd6bdf0fca"
vendor/bin/phpunit test/Integration

TODO

  • Convert documentation to markdown
    • Point "getting started" link in readme to docs
  • Use proper namespacing
  • Add dependencies to composer (eg, ext-soap)
  • Create tests
  • Run tests against a developer edition
  • Check and set up code coverage
  • Final cleanup commit
    • replace uuf6429 with developerforce (eg; readme, composer)
    • replace Major-refactor with master (eg; badges)

uuf6429/force.com-toolkit-for-php 适用场景与选型建议

uuf6429/force.com-toolkit-for-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.13k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2019 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 uuf6429/force.com-toolkit-for-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 4
  • Forks: 215
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2019-02-17