How to Create New Salesforce Custom Object Using PHP Script

We can creates custom object in salesforce using PHP Script.

try {
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection('soapclient/Partnetwsdl.xml');
$loginResult = $mySforceConnection->login('', 'cc20127B8fw0x92YerGiV4zak5ucMc');
$myMetadataConnection = new SforceMetadataClient('soapclient./metadata.xml', $loginResult, $mySforceConnection);

//Create object
$customObject = new SforceCustomObject();
$customObject->fullName = 'CustomObjFromPHP__c';
$customObject->deploymentStatus = DEPLOYMENT_STATUS_DEPLOYED;

$customObject->setDescription("A description");
$customObject->setLabel("My Custom Obj from PHP");
$customField = new SforceCustomField();
$customField->setDescription('Description of New Field');
$customField->setLabel('My Custom Field Label');

$customObject->nameField = $customField;

$customObject->pluralLabel = 'My Custom Objs from PHP';
$customObject->sharingModel = SHARING_MODEL_READWRITE;

} catch (Exception $e) {
echo $myMetadataConnection->getLastRequest();
echo $e->faultstring;


You can find the Basic Tutorials about PHP and Salesforce Implementation using Below URL

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

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