This extension allow you to integrate your Yii2 application with SalesForce.com via regular ActiveRecordInterface.
Run
composer require --prefer-dist bigdropinc/yii2-salesforce
- Define
salesforce
component:
<?php
return [
'components' => [
'salesforce' => [
'class' => '\sokyrko\yii\salesforce\components\SalesforceComponent',
'consumerKey' => 'applicationConsumerKey',
'consumerSecret' => 'applicationConsumerSecret',
'username' => 'salesForceLogin',
'password' => 'salesForcePassword' . 'salesForceAccountSecretKey',
'loginUrl' => 'salesForceLoginUrl', // eg: https://login.salesforce.com/
],
],
];
- Define salesforce entity with public fields:
<?php
namespace console\models\salesforce;
use sokyrko\yii\salesforce\data\ActiveRecord;
class Account extends ActiveRecord
{
protected static $isCustom = false; // set false if is not custom model
/** @var string */
public $Id;
/** @var string */
public $Name;
}
- Use same as Yii2 ActiveRecord:
<?php
$account = console\models\salesforce\Account::findOne(['Name' => 'My name']);
var_dump($account); // {Id: 'some-salesforce-id', Name: 'My name'}
You can see more examples for query builder in tests.
- Create, update, delete records
- Complete ActiveRecord tests