Salesforce | Get list of Salesforce sobjects and fields in PHP

Author - Webner

Problem: How to get list of all the Salesforce sobjects in php. Also get fields of each sobject.

Solution: First we need to install Salesforce php toolkit for this. Once you have it then this is the sample code:

require_once(SFDCPHPtoolkit / soapclient / SforcePartnerClient.php ');
$mySforceConnection = new SforcePartnerClient(); $mySforceConnection - > createConnection("partner.wsdl.xml"); $mySforceConnection - > login(USERNAME, PASSWORD.SECURITY_TOKEN); // Here we need to specify salesforce username, password, token.
$result = $mySforceConnection - > describeGlobal(); // Method to fetch all sobjects from salesforce
foreach($result - > sobjects as $key => $val) {
Echo $val - > name.’, ’;


Account, Contact, Lead……….

Code Sample To Fetch Subject Fields:

$SFobj = ’Account’;
$result = $mySforceConnection - > - > describeSObject($SFobj);
foreach($result - > fields as $key => $val) {
Echo $val - > name.’, ’;


Name, Phone…..

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *