Download the PHP package brightecapital/salesforce-orm without Composer
On this page you can find all versions of the php package brightecapital/salesforce-orm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download brightecapital/salesforce-orm
More information about brightecapital/salesforce-orm
Files in brightecapital/salesforce-orm
Download brightecapital/salesforce-orm
More information about brightecapital/salesforce-orm
Files in brightecapital/salesforce-orm
Vendor brightecapital
Package salesforce-orm
Short Description Salesforce ORM
License MIT
Homepage https://github.com/brightecapital/
Package salesforce-orm
Short Description Salesforce ORM
License MIT
Homepage https://github.com/brightecapital/
Please rate this library. Is it a good library?
Informations about the package salesforce-orm
Salesforce ORM for PHP: Doctrine style entities, entity manager and repository
Configuration
composer.json
"require": { "brightecapital/salesforce-orm": "^1.4.2" }
Run
composer require brightecapital/salesforce-orm
Sample code
EntityManager
$config = [ 'clientId' => 'yourSalesforceClientId' 'clientSecret' => "yourSalesforceSecret" 'path' => 'yourSalesforcePath' 'username' => 'yourSalesforceUsername' 'password' => 'yourSalesforcePassword' 'apiVersion' => 'yourSalesforceApiVersion' ]; $conn = new \Salesforce\Client\Connection($config); $entityManager = new \Salesforce\ORM\EntityManager($conn);
Repository
/* @var \Salesforce\ORM\Repository */ $accountRepository = $entityManager->getRepository(Account::class);
class AccountRepository extends Repository { protected $className = Account::class; } $accountRepository = new AccountRepository($entityManager);
Objects
/* @var Account $account */ $account = $entityManager->getRepository(Account::class)->find('0010p000002Wam9AAC'); $account = $accountRepository->find('0010p000002Wam9AAC');
$account = new Account();
Create|Update Object
$account = new Account(); $account->setName('Your Name); $account->setWebsite('YourWebsite); $accountRepository->save($account); // this will create a new Account entity $account = $entityManager->getRepository(Account::class)->find('0010p000002Wam9AAC'); $account->setWebsite('YourWebsite); $account->setName('YourName'); $accountRepository->save($account); // this will update a the current Account entity
Entity and Field
/** * Salesforce Account * * @package Salesforce\Entity * @SF\Object(name="Account") */ class Account extends Entity { /** * @var string * @SF\Field(name="Name", required=true) */ protected $name; /** * @var string * @SF\Field(name="Website") */ protected $website; }
- @SF\Object(name="Account"): indicate that this class is mapping to Salesforce Account object
- @SF\Field(name="Name") : indicate that the property is mapping to filed 'Name' in Salesforce Account object
Relations, Required, Validations
/**
- Salesforce Account
- @package Salesforce\Entity
-
@SF\Object(name="Account") */ class Account extends Entity { /**
- @var string
- @SF\Field(name="Name", required=true) */ protected $name;
/**
- @var string
- @SF\Field(name="Website")
- @SF\Url(value=true) */ protected $website;
/**
- @var array
- @SF\OneToMany(name="Contacts", targetClass="App\Domain\Marketing\Salesforce\Entity\Contact", field="Id", targetField="AccountId", lazy=false) */ protected $contacts;
}
- @SF\OneToMany(name="Contacts", targetClass="App\Domain\Marketing\Salesforce\Entity\Contact", field="Id", targetField="AccountId", lazy=false): indicate that one Account has many Contact
- targetClass : the implemented class of Contact
- field: the field/column of Account object
- targetField: the field/column of the target Contact object
-
lazy: if lazy = false, the repository will autoload list of Contact of the Account when you do (default = true)
$account = $accountRepository->find('0010p000002Wam9AAC');
- @SF\Required(value=true): indicate that this field is required. An exception will be thrown if this property is not set when saving the entity
- @SF\Url(value=true): indicate that this field is a url. An exception will be thrown if the value of this property is not an url
Available validations: Url, Email, Date
Find and Count
// Find Account by conditions, by default lazy loading = false (will load relations) $accounts = $accountRepo->findBy(['Company_Name__c = Adant Services Group Pty Ltd']); // Find all Account, by default lazy loading = true (will not load relations) $accounts = $accountRepo->findAll(); // Find total number of Account $count = $accountRepository->count();
Job (Bulk upload)
All versions of salesforce-orm with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1||^7.0
eventfarm/restforcephp Version dev-master
doctrine/annotations Version ^1.6
psr/log Version ^1.1
league/csv Version 9.3
eventfarm/restforcephp Version dev-master
doctrine/annotations Version ^1.6
psr/log Version ^1.1
league/csv Version 9.3
The package brightecapital/salesforce-orm contains the following files
Loading the files please wait ....