stratease/salesforcery
Composer 安装命令:
composer require stratease/salesforcery
包简介
A PHP Salesforce ORM, inspired by Eloquent's API.
README 文档
README
A PHP ORM for Salesforce client applications, utilizing an OAuth2 REST client. Inspired by Eloquent's simple API.
Setup
1. Setting up a Connected App
You need to create a Connected App to generate the client_id and client_secret values for the OAuth2 connection. Once created use the credentials to register a connection.
2. Installation
composer require stratease/salesforcery
3. Connection
use Stratease\Salesforcery\Salesforce\Connection\REST\Authentication\PasswordAuthentication; use Stratease\Salesforcery\Salesforce\Connection\REST\Client; use Stratease\Salesforcery\Salesforce\Database\Model; $authentication = new PasswordAuthentication([ 'grant_type' => 'password', 'client_id' => 'your app ID', 'client_secret' => 'your app secret', 'username' => 'salesforce@user.com', 'password' => 'password+token', 'authorization_url' => 'https://test.salesforce.com/' ]); // Typically https://login.salesforce.com, for testing use https://test.salesforce.com $authentication->setEndpoint('https://test.salesforce.com/'); $client = new Client($authentication); $response = $client->query("SELECT Id FROM Account LIMIT 1"); // Should output a response with a 'records' key that conains an array of results. print_r($response); // Register your connection so the ORM can connect Model::registerConnection($client); // Your model to connect to the Salesforce Account object $account = Your/Models/Account::findOneBy('Id', 'abc123');
Examples
Defining a model
For a simple setup...
use Stratease\Salesforcery\Salesforce\Database\Model; class Account extends Model { // Account maps to Account in Salesforce, nothing else required. }
More advanced usage...
use Stratease\Salesforcery\Salesforce\Database\Model; class Product extends Model { public static $resourceName = 'Product2'; }
- Extend
Stratease\Salesforcery\Salesforce\Database\Modeland you're set! Sorta... - The model's Salesforce Object name is mapped by default via the {ClassName} -> {ObjectName}. You can override by defining the
resourceNameproperty. - Explicit field definitions allowed with option to override.
get{Field}() - Will use
SchemaInspectorto discover fields for this resource and automatically hydrate instances with the fields
Query Objects
// Account is returned $account = Account::findOneBy('Name', 'Acme Corp'); // An iterable Collection is returned $accountCollection = Account::findBy(['OwnerId' => '123', 'Status' => 'Active']); // performs an AND expression on the associative array foreach($accountCollection as $account) { echo "\n".$account->Name; }
Modify Objects
// create $account = new Account(); $account->Name = 'Acme Uber Corp'; $account->save(); // update $account2 = Account::findOneBy('Name', 'Acme Uber Corp'); $account2->Name = 'Acme Uber Inc.'; $account2->save(); // delete $account2->delete();
Salesforce
This library uses Salesforces REST API. Tested on version 39.
Todo
- Object relations mapping, i.e.
$contact->phone->isMobile - Add more REST endpoint support
- Batch REST integration
- Object -> field schema cache. As it stands it will request the schema
n * Modelstimes per run. So if you do a series of requests utilizingAccountandUsermodels, it will request the schema twice, once for each model. - Query builder object
- Look into extended Eloquent more formally.
- Test with other php versions. Was developed on
7.1 - Docker environment for tests. As it stands now tests require a connection to a sandbox environment. Preferred setup for now in order to validate various Salesforce REST protocols are passing muster.
- Currently only support for OAuth2
passwordgrant type. Accepting pull requests for other authorization protocols.
stratease/salesforcery 适用场景与选型建议
stratease/salesforcery 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 964 次下载、GitHub Stars 达 6, 最近一次更新时间为 2018 年 03 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「orm」 「php」 「rest」 「client」 「salesforce」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stratease/salesforcery 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stratease/salesforcery 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stratease/salesforcery 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Kinikit - PHP Application development framework MVC component
Store your language lines in the database, yaml or other sources
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
统计信息
- 总下载量: 964
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2018-03-08