PHPackages                             voycey/cakephp-salesforce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. voycey/cakephp-salesforce

ActiveCakephp-plugin

voycey/cakephp-salesforce
=========================

Salesforce Enterprise CakePHP Datasource

0.1.5b(10y ago)51615MITPHPPHP &gt;=5.4.16

Since Dec 9Pushed 7y ago2 watchersCompare

[ Source](https://github.com/voycey/cakephp-salesforce)[ Packagist](https://packagist.org/packages/voycey/cakephp-salesforce)[ Docs](https://github.com/voycey/cakephp-salesforce)[ RSS](/packages/voycey-cakephp-salesforce/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

Salesforce Datasource plugin for CakePHP 3.x
============================================

[](#salesforce-datasource-plugin-for-cakephp-3x)

[![Latest Stable Version](https://camo.githubusercontent.com/f457271cb9e57204b37593c25aae91556457487157c600122b336163cec245f9/68747470733a2f2f706f7365722e707567782e6f72672f766f796365792f63616b657068702d73616c6573666f7263652f762f737461626c65)](https://packagist.org/packages/voycey/cakephp-salesforce) [![Total Downloads](https://camo.githubusercontent.com/b6aa18b075b922f2a3dc8d0293f465ccfe4cd14cbaaf44d05340d47e3b571890/68747470733a2f2f706f7365722e707567782e6f72672f766f796365792f63616b657068702d73616c6573666f7263652f646f776e6c6f616473)](https://packagist.org/packages/voycey/cakephp-salesforce) [![Latest Unstable Version](https://camo.githubusercontent.com/e7689047ab15631fa448e4c00d5c62b47047fb7059c4c198e92303c7dfd3869b/68747470733a2f2f706f7365722e707567782e6f72672f766f796365792f63616b657068702d73616c6573666f7263652f762f756e737461626c65)](https://packagist.org/packages/voycey/cakephp-salesforce) [![License](https://camo.githubusercontent.com/b85b2031cf33252cc8a58758a96283aea2f73778c08f2a5894ca9efd4cfeaf42/68747470733a2f2f706f7365722e707567782e6f72672f766f796365792f63616b657068702d73616c6573666f7263652f6c6963656e7365)](https://packagist.org/packages/voycey/cakephp-salesforce)

For earlier versions of CakePHP (2.x)
-------------------------------------

[](#for-earlier-versions-of-cakephp-2x)

Please use the 2.x branch and follow the readme instructions under that for usage instructions

Installation
------------

[](#installation)

**This plugin is now in Beta**

- API Compatible Saving &amp; Reading is working
- Schema &amp; 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](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require voycey/cakephp-salesforce

```

Information
-----------

[](#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.

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.

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?)

Notes
-----

[](#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 &amp; 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
-----

[](#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**

```

4. Get your Enterprise WSDL and place it in the app `config` directory
5. Create a test controller that looks something like this

```
