Download the PHP package lyonstahl/salesforce without Composer

On this page you can find all versions of the php package lyonstahl/salesforce. 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

Salesforce REST API Client

Installation

Ensure you have composer installed, then run the following command:

composer require lyonstahl/salesforce

That will fetch the library and its dependencies inside your vendor folder.

If you want a simple API for bulding SOQL queries, we suggest lyonstahl/soql-builder

Requirements

Features

Setting up a Connected App

Before you begin, you need to have set up a "Connected App" in Salesforce and get a consumerKey, consumerSecret, username, and password to allow Api access.

Note, this process may vary depending on changes to the Salesforce website, or on your Salesforce account and settings.

_Check Salesforce's Help Docs to verify._

  1. Log into to your Salesforce org
  2. Click on Setup in the upper right-hand menu
  3. Under Build click Create → Apps
  4. Scroll to the bottom and click "New" under Connected Apps.
  5. Enter the following details for the remote application:
    • Connected App Name
    • API Name
    • Contact Email
    • Under the API dropdown, enable OAuth Settings
    • Callback URL
    • Select Access Scope (If you need a refresh token, specify it here)
  6. Click Save, and store your access credentials in a safe place.

Usage

Creating a new Api client and connecting:

The following examples use a Salesforce object named Example that has a field Name.

Executing Basic SOQL Queries:

If you need to use php values in your query, put {tokens} in your SOQL and pass the values separately via query()'s second argument. The values will be properly quoted and escaped based on their type, and interpolated into the query:

Fetching a Record by Id:

Creating a new Record:

Updating an existing Record:

Deleting a Record:

Advanced Usage

Extending the Record class

The included LyonStahl\Salesforce\Record class can be used without modification as a generic "salesforce record" implementation - it will automatically set properties based on what's fetched from the Api. However, the intent is that applications will extend from it and define the properties needed for each of their Salesforce objects. This allows for a consistent schema that your code can rely on, and even lets you implement some level of validation directly in your application.

To build your own Salesforce Object, you must:

Using our "Example" object from above,

Inline Records and Record Lists

SOQL allows queries for nested objects and queries, which appear in results as inline records and query results respectively. This library does understand results from such queries, but your Record subclasses must define properties in a particular way to support them.

For example, a query similar to SELECT Manager.Id, Manager.Name, (SELECT Id, Name FROM Members) FROM Teams would require a Record class like so:

Where there is an inline object, the property should be typed as the corresponding Record subclass. For any record type where you're not making a Record subclass, type the property as Record — though this is obviously less useful.

Where there is a subquery, the property should be typed as a Result instance. Among other things, this allows the Result to support paginated subqueries.

Object Mapping

Finally, to allow the Api Client take advantage of your subclasses, you must provide an $objectMap so it knows which PHP classes correspond to which Salesforce record types. Without this, you'll end up with generic Record instances for everything. Nested Results will be provided the same $objectMap as their parent Result instance.

Field Validation

Some basic validation functions are included in LyonStahl\Salesforce\Validator. These methods all take the value to validate as the first argument, and can have other arguments depending on needs. Follow this same pattern to implement additional validation functions for your own objects as needed.

Handling Errors

All Runtime Exceptions thrown from this library will be an instance of LyonStahl\Salesforce\Error.

Exceptions are grouped into the following types:

Running for development with Docker

We have included a Dockerfile to make it easy to run the tests and debug the code. You must have Docker installed. The following commands will build the image and run the container:

  1. docker build -t lyonstahl/salesforce --build-arg PHP_VERSION=8 .
  2. docker run -it --rm -v ${PWD}:/var/www/sapi lyonstahl/salesforce sh

Debugging with XDebug in VSCode

Docker image is configured with XDebug. To debug the code with VSCode, follow these steps:

  1. Install the PHP Debug extension in VSCode
  2. Add a new PHP Debug configuration in VSCode:

    {
        "name": "XDebug Docker",
        "type": "php",
        "request": "launch",
        "port": 9003,
        "pathMappings": {
            "/var/www/sapi/": "${workspaceRoot}/"
        }
    }
  3. docker run -it --rm -v ${PWD}:/var/www/sapi --add-host host.docker.internal:host-gateway lyonstahl/salesforce sh
  4. Start debugging in VSCode with the 'XDebug Docker' configuration.

Testing

This library ships with PHPUnit for development. Composer file has been configured with some scripts, run the following command to run the tests:

composer test

All versions of salesforce with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
guzzlehttp/guzzle Version ^7.8
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 lyonstahl/salesforce contains the following files

Loading the files please wait ....