Download the PHP package napp/salesforce-api without Composer

On this page you can find all versions of the php package napp/salesforce-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package salesforce-api

Current Version License Scrutinizer Travis

Salesforce PHP Library

A simple library for interacting with the Salesforce REST API.

Methods for setting up a connection, requesting an access token, refreshing the access token, saving the access token, and making calls against the API.

Getting started

Installation: The package should be installed through composer and locked to a major version

Getting an OAuth Token:

With User interaction: You need to fetch an access token for a user, all followup requests will be performed against this user.

When having the username and password: To use this method you also need the security token to be appended to the password. Keep in mind this method is to be used as a replacement for the old API Key workflow.

Performing an action: Once you have an access token you can perform requests against the API.

The token will expire after an hour so you should make sure you're checking the expiry time and refreshing accordingly.

Setting up the Salesforce client

The client can be configured in two ways, you can call the static create method above passing in the login url and oauth details or you can use a configuration object as in the example below. This is useful when you need to resolve the client out of an ioc container.

The configuration data for the client is passed in through a config file which must implement \Napp\Salesforce\ClientConfigInterface

For example

A config class is provided and can be used if needed. \Napp\Salesforce\ClientConfig

The Salesforce client can then be instantiated with the config object and an instance of the Guzzle v4 client.

Authentication

Authentication happens via oauth2 and the login url can be generated using the getLoginUrl method, you should pass this your return url for the send stage of the oauth process.

You should redirect the user to this returned url, on completion they will be redirected back with a code in the query string.

The second stage of the authentication can then be completed.

The token returned from here is the raw data and can be passed to the access token generator to make an AccessToken.

Storing the access token

This access token should be stored. A method to store this on the file system is provided but this isn't required.

The example above uses the php session to achieve the same result.

The LocalFileStore object needs to be instantiated with access to the token generator and a config class which implements \Napp\Salesforce\TokenStore\LocalFileConfigInterface

The token store can then be created and used to save the access token to the local file system as well as fetching a previously saved token.

Refreshing the token

The access token only lasts 1 hour before expiring so you should regularly check its status and refresh it accordingly.

Making requests

Before making a request you should instantiate the client as above and then assign the access token to it.

Performing an SOQL Query

This is a powerful option for performing general queries against your salesforce data. Simply pass a valid query to the search method and the resulting data will be returned.

Fetching a single record

If you know the id and type of a record you can fetch a set of fields from it.

Creating and updating records

The process for creating and updating records is very similar and can be performed as follows. The createRecord method will return the id of the newly created record.

Deleting records

Records can be deleted based on their id and type.

Errors

If something goes wrong the library will throw an exception.

If its an authentication exception such as an expired token this will be as Napp\Salesforce\Exceptions\AuthenticationException, you can get the exact details using the methods getMessage and getErrorCode.

All other errors will be Napp\Salesforce\Exceptions\RequestException, the salesforce error will be in the message


All versions of salesforce-api with dependencies

PHP Build Version
Package Version
Requires ext-json Version *
php Version ^7.4|^8.0
nesbot/carbon Version ^2.0
guzzlehttp/guzzle Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package napp/salesforce-api contains the following files

Loading the files please wait ....