2017 © Pedro PelĂĄez
 

cakephp-plugin cakephp-salesforce

image

voycey/cakephp-salesforce

  • Thursday, August 2, 2018
  • by voycey
  • Repository
  • 2 Watchers
  • 4 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 10 Versions
  • 3 % Grown

The README.md

Salesforce Datasource plugin for CakePHP 3.x

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

For earlier versions of CakePHP (2.x)

Please use the 2.x branch and follow the readme instructions under that for usage instructions, (*2)

Installation

This plugin is now in Beta, (*3)

  • API Compatible Saving & Reading is working
  • Schema & Connection Caching is working
  • Bear in mind that any API interaction is expensive, you should be using this with a deferred execution method.

You can install this plugin into your CakePHP application using composer., (*4)

The recommended way to install composer packages is:, (*5)

composer require voycey/cakephp-salesforce

Information

This has been somewhat of a learning curve for me, due to the nature of how Datasources are created in 3.x. I have tried to follow the patterns of the other SQL-like datasources, Eager loading is used (as in SQL sources) and there is a limited dialect., (*6)

I would have liked to do some processing on the WSDL as I did in my 2.x datasource in order to create the schema however this wasn't possible as I now needed to see the status of certain fields (readable / updateable) which has caused a need for a further call to the API., (*7)

Any API connections are cached for 1 hour (Salesforce timeout is 2 hours), after this time the connection will be refreshed (but this shouldn't matter as you are using this with a deferred execution method right?), (*8)

Notes

  1. This uses the PHP-Force.com toolkit as a dependency
  2. This uses SOAP and NOT REST (Because of Reasonsℱ)
  3. I have only tested this with the Contact and Account SObjects, the Contact example is included in the plugin, to create more models to interact with other SObjects copy SalesforceContactTable as a template (see instructions below).
  4. Feel free to submit pull requests - here are a few examples of things I'd like to implement / test
    1. Associations between native Cake Tables & API Tables (I'm not sure this is actually possible though!)
    2. Tests (Most can probably be ripped from the core tests I assume) - I don't plan to do many as to test properly would require access to the API.
    3. Testing with all SObjects (currently I have only tested with a few but from experience with my version 2.x datasource this is usually enough to work with all SObjects)
    4. Efficiency increases.

Usage

  1. Do composer reqire as above
  2. Add Plugin::load('Salesforce', ['bootstrap' => true, 'routes' => true]); to your bootstrap.php
  3. Create the connection in app.php like this:
  'salesforce' => [
     'className' => 'Salesforce\Database\SalesforceConnection',
     'driver' => 'Salesforce\Database\Driver\Salesforce',
     'persistent' => false,
     'username' => getenv("SF_USER"),
     'password' => getenv("SF_PASSWORD"),
     'quoteIdentifiers' => false,
     'my_wsdl' => 'enterprise.wsdl.xml'
  ],
    **Your SF_PASSWORD should be your password + security token**
  1. Get your Enterprise WSDL and place it in the app config directory
  2. Create a test controller that looks something like this, (*9)

    <?php
     namespace App\Controller;
    
     use App\Controller\AppController;
     use Cake\Event\Event;
    
     class SalesforcesController extends AppController 
     {
    
        public function beforeFilter(Event $event)
        {
            parent::beforeFilter($event);
        }
    
        public function index()
        {
            $this->autoRender = false;
            $this->loadModel('Salesforce.SalesforceContact');
            $query = $this->SalesforceContact->find('all')
                        ->select(['Id','Email','LastName'])
                        ->where(['Email' => "info@salesforce.com"]
                    );
    
            foreach ($query as $row) {
              echo "<pre>";
              print_r($row);
              echo "</pre>";
            }
    
        }
     }
    

Then browse to /salesforces and you should have a couple of the standard Salesforce records. If not then go back and repeat these steps. If you get an interesting error message then.... well sorry, I'm sure it will get fixed as I use it more., (*10)

Interfacing with other Salesforce Items

This should simply be a case of extending "SalesforcesTable" rather than Table with your chosen Item (e.g. Account), (*11)

 <?php
  namespace App\Model\Table;

  use Salesforce\Model\Entity\Salesforce;
  use Salesforce\Model\Table\SalesforcesTable;

  class SalesforceAccountTable extends SalesforcesTable
  {
      public $name = "Account";

      /**
       * Initialize method
       *
       * @param  array $config The configuration for the Table.
       * @return void
       */
      public function initialize(array $config)
      {
          parent::initialize($config);

          $this->table('Account');
          $this->displayField('Name');
          $this->primaryKey('Id');
      }
  }

The Versions

02/08 2018

2.x-dev

2.9999999.9999999.9999999-dev

  Sources   Download

30/08 2017

dev-master

9999999-dev https://github.com/voycey/cakephp-salesforce

Salesforce Enterprise CakePHP Datasource

  Sources   Download

MIT

The Requires

 

The Development Requires

14/01 2016

0.1.5b

0.1.5.0-beta https://github.com/voycey/cakephp-salesforce

Salesforce Enterprise CakePHP Datasource

  Sources   Download

MIT

The Requires

 

The Development Requires

14/12 2015

0.1.3b

0.1.3.0-beta https://github.com/voycey/salesforce-datasource-cakephp-3.x

Salesforce plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

14/12 2015

0.1.2b

0.1.2.0-beta https://github.com/voycey/salesforce-datasource-cakephp-3.x

Salesforce plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

14/12 2015

0.1.1b

0.1.1.0-beta https://github.com/voycey/salesforce-datasource-cakephp-3.x

Salesforce plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

14/12 2015

0.1b

0.1.0.0-beta https://github.com/voycey/salesforce-datasource-cakephp-3.x

Salesforce plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

11/12 2015

0.0.3a

0.0.3.0-alpha https://github.com/voycey/salesforce-datasource-cakephp-3.x

Salesforce plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

11/12 2015

0.0.2a

0.0.2.0-alpha https://github.com/voycey/salesforce-datasource-cakephp-3.x

Salesforce plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

09/12 2015

0.0.1a

0.0.1.0-alpha https://github.com/voycey/salesforce-datasource-cakephp-3.x

Salesforce plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires