PHP and Salesforce Integration

We recently completed a project involving integrating Salesforce with PHP. The article describes that there is one external server which contains MySQL data base and Php scripts or Web services

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. PHP is now installed on more than 244 million websites and 2.1 million web servers. Originally created by Rasmus Lerdorf in 1995, the reference implementation of PHP is now produced by The PHP Group. While PHP originally stood for Personal Home Page, it now stands for PHP: Hypertext Preprocessor, a recursive acronym.

MySql database has some tables which contains events ata and php web services are fetching that data.

In this PHP – Salesforce Integration blog we are going to elaborate the integration of Salesforce Event object (Custom) with the external server which has one MySql database and PHP web service -Which will fetch data from MySQL database and give return fetched data to Salesforce and vice versa.

First we have to write a PHP web service.

Then we should write a WSDL file of PHP web service

After that we should create apex class through this WSDL Service. Using that generated class we can call PHP web service.

SFDC   ExternalServer (Php web service & MySql)
Search Event <--- Php fetch Events from MySql based on Keyword and location given by Salesforce.
Create Event ---> User will filll the details on SFDC and php will create an event in
My Events <--- It will display all user created events from MySql database

Working of the External Server (Php webservice & MySql database) – Salesforce Integration

  • User can search events using any keywords and Location from Salesforce side. On search salesforce will hit Php web service and php will search events from MySql database and return to SFDC.
  • There is dynamic autocomplete list of location and keyword on Salesforce side which display data from MySql using php webservice.
  • User can create his own events. These events will be stored on MySql database using php.

Technical Approach taken for Integration

  • Open standards SOAP Web service is used to fetch or store the Data.
  • Integration Coding has done at the Salesforce side using Apex language and web service has been created in Php.

The details of the developed Apex components and php webservice with their functionality are as follows:

Class – SerachEvents

  • This class has the logic to fetch the auto complete list of keyword and location from external server or for that it makes callout to php web service which is on external server.
  • It has logic to search events from MySql database based on keyword and location and for that class makes callout to another php web service which will fetch events from MySql and return to salesforce.

Class – CreateEvent

It contains the logic to store the Events in MySql database. Salesforce will make call to create event php web service which will store event in MySql database.

Class – MyEvents

It is used to fetch all the events. Salesforce will call php web service and it will fetch all user created events from MySql and return to salesforce.

Snapshots of Implementation

Search Event Screen in Salesforce

PHP And Salesforce Integration Screenshot

Create Event screen in Salesforce

PHP And Salesforce Integration Screenshot

My Event Screen in Salesforce

PHP And Salesforce Integration Screenshot

For any query on PHP Salesforce Integration, contact