PHPackages                             antogkou/laravel-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. [API Development](/categories/api)
4. /
5. antogkou/laravel-salesforce

ActiveLibrary[API Development](/categories/api)

antogkou/laravel-salesforce
===========================

A Laravel package for Salesforce API integration

v3.0.0(1y ago)644.0k↓24.8%[3 PRs](https://github.com/antogkou/laravel-salesforce/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Nov 22Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/antogkou/laravel-salesforce)[ Packagist](https://packagist.org/packages/antogkou/laravel-salesforce)[ RSS](/packages/antogkou-laravel-salesforce/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (11)Versions (19)Used By (0)

Laravel Salesforce Integration
==============================

[](#laravel-salesforce-integration)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7980ba37da0a488821959b0eeac7379f7cd4a10c3a11bdf52fc77940017b5c65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e746f676b6f752f6c61726176656c2d73616c6573666f7263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/antogkou/laravel-salesforce)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7a26e3427cd53dd893daea0b77f956da84ad846825162fd998e0f139fe4a784d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f616e746f676b6f752f6c61726176656c2d73616c6573666f7263652f54657374733f6c6162656c3d7465737473)](https://github.com/antogkou/laravel-salesforce/actions?query=workflow%3ATests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3c6352f9d6d28a1b3138f0cc1c53ec15537ad667f900fdcf51f18e472d40f7f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e746f676b6f752f6c61726176656c2d73616c6573666f7263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/antogkou/laravel-salesforce)[![License](https://camo.githubusercontent.com/daeea0f619b026c59f242c276b9ed3ba582f22b8c77966e1fe053b613fdc40d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616e746f676b6f752f6c61726176656c2d73616c6573666f7263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/antogkou/laravel-salesforce)

A Laravel package for seamless Salesforce API integration, providing an elegant way to interact with Salesforce's REST APIs.

Features
--------

[](#features)

- 🚀 Simple and intuitive API
- 🔑 Flexible authentication options
- 🔒 Supports custom Apex class authentication
- 🌐 OAuth 2.0 integration
- 📦 Automatic token management
- 🔐 Optional certificate-based authentication
- ⚡ Request/Response interceptors

Requirements
------------

[](#requirements)

- PHP 8.2 or higher (Compatible with PHP 8.2, 8.3, 8.4)
- Laravel 11.0 or higher (Laravel 12 support is experimental)
- Composer 2.0 or higher

Version Compatibility
---------------------

[](#version-compatibility)

LaravelPHPPackage10.x8.1, 8.2, 8.31.x11.x8.2, 8.32.x11.x8.43.x12.x8.2, 8.3, 8.43.xInstallation
------------

[](#installation)

1. Install the package via composer:

```
composer require antogkou/laravel-salesforce
```

2. Publish the configuration:

```
# Publish config file
php artisan vendor:publish --tag="salesforce-config"

# If using certificate authentication
php artisan vendor:publish --tag="salesforce-certificates"
```

Configuration
-------------

[](#configuration)

### Multiple Connections

[](#multiple-connections)

This package supports multiple Salesforce connections. You can configure them in your `.env` file and `config/salesforce.php`:

```
# Default connection
SALESFORCE_CONNECTION=default

# Default connection credentials
SALESFORCE_CLIENT_ID=your-client-id
SALESFORCE_CLIENT_SECRET=your-client-secret
SALESFORCE_USERNAME=your-username
SALESFORCE_PASSWORD=your-password
SALESFORCE_SECURITY_TOKEN=your-security-token
SALESFORCE_APEX_URI=https://salesforce-instance.com/services/apexrest

# Sandbox connection credentials
SALESFORCE_SANDBOX_CLIENT_ID=sandbox-client-id
SALESFORCE_SANDBOX_CLIENT_SECRET=sandbox-client-secret
SALESFORCE_SANDBOX_USERNAME=sandbox-username
SALESFORCE_SANDBOX_PASSWORD=sandbox-password
SALESFORCE_SANDBOX_SECURITY_TOKEN=sandbox-security-token
SALESFORCE_SANDBOX_APEX_URI=https://sandbox-instance.com/services/apexrest
```

You can switch between connections at runtime:

```
use Antogkou\LaravelSalesforce\Facades\Salesforce;

// Use the default connection
$response = Salesforce::get('/endpoint');

// Switch to sandbox connection
$response = Salesforce::connection('sandbox')->get('/endpoint');

// Switch back to default
$response = Salesforce::connection('default')->get('/endpoint');

// Chain with other methods
$response = Salesforce::connection('sandbox')
    ->setEmail('user@example.com')
    ->get('/endpoint');

// Use environment-specific connections
$response = Salesforce::whenEnvironment('sandbox', 'staging')
    ->get('/endpoint'); // Uses 'sandbox' connection only in staging environment

// Use environment-specific connections with multiple environments
$response = Salesforce::whenEnvironment('sandbox', ['staging', 'testing'])
    ->get('/endpoint'); // Uses 'sandbox' connection in both staging and testing environments

// If the environment-specific connection is not configured, falls back to default
$response = Salesforce::whenEnvironment('sandbox', 'production')
    ->get('/endpoint'); // Uses default connection in production
```

Each connection can have its own:

- OAuth credentials
- API endpoints
- Application authentication
- Certificate configuration
- Default user email

The package will always use the default connection unless explicitly changed using `connection()` or `whenEnvironment()`. If an environment-specific connection is set but not configured, it will automatically fall back to the default connection.

### Required Configuration

[](#required-configuration)

Add these essential environment variables to your `.env` file:

```
# Required: Salesforce OAuth Credentials
SALESFORCE_CLIENT_ID=your-client-id
SALESFORCE_CLIENT_SECRET=your-client-secret
SALESFORCE_USERNAME=your-username
SALESFORCE_PASSWORD=your-password
SALESFORCE_SECURITY_TOKEN=your-security-token
SALESFORCE_APEX_URI=https://salesforce-instance.com/services/apexrest

# Optional: Default endpoints (these defaults are for sandboxes)
SALESFORCE_TOKEN_URI=https://test.salesforce.com/services/oauth2/token
```

### Optional: Custom Apex Authentication

[](#optional-custom-apex-authentication)

If your Salesforce Apex classes implement custom application-level authentication, you can configure it using:

```
# Optional: Custom Apex Authentication
SALESFORCE_APP_UUID=your-app-uuid
SALESFORCE_APP_KEY=your-app-key
```

This adds `x-app-uuid` and `x-app-key` headers to your requests, which you can validate in your Apex classes:

```
@RestResource(urlMapping='/your-endpoint/*')
global with sharing class YourApexClass {
    @HttpGet
    global static Response doGet() {
        // Validate application credentials
        String appUuid = RestContext.request.headers.get('x-app-uuid');
        String appKey = RestContext.request.headers.get('x-app-key');

        if (!YourAuthService.validateApp(appUuid, appKey)) {
            throw new CustomException('Invalid application credentials');
        }

        // Your endpoint logic...
    }
}
```

### Optional: Certificate Authentication

[](#optional-certificate-authentication)

For certificate-based authentication:

```
# Optional: Certificate Authentication
SALESFORCE_CERTIFICATE=cert.pem
SALESFORCE_CERTIFICATE_KEY=cert.key
```

### Optional: Default User Context

[](#optional-default-user-context)

```
# Optional: Default User Email
SALESFORCE_DEFAULT_USER_EMAIL=default@example.com
```

Basic Usage
-----------

[](#basic-usage)

```
use Antogkou\LaravelSalesforce\Facades\Salesforce;

// Basic request
$response = Salesforce::get('/endpoint');

// With custom user context
$response = Salesforce::setEmail('user@example.com')
    ->get('/endpoint');

// With custom headers
$response = Salesforce::post('/endpoint', $data, [
    'Custom-Header' => 'Value'
]);
```

### Advanced Usage

[](#advanced-usage)

```
// Set custom user email for the request
$response = Salesforce::setEmail('user@example.com')
    ->get('/endpoint');

// With query parameters
$response = Salesforce::get('/endpoint', [
    'limit' => 10,
    'offset' => 0
]);

// With custom headers
$response = Salesforce::post('/endpoint', $data, [
    'Custom-Header' => 'Value'
]);

// Handling responses
$response = Salesforce::get('/endpoint');

if ($response->successful()) {
    $data = $response->json();
    $status = $response->status();
} else {
    $error = $response->json('error');
}
```

### Error Handling

[](#error-handling)

```
use Antogkou\LaravelSalesforce\Exceptions\SalesforceException;
use Illuminate\Http\Client\RequestException;

try {
    $response = Salesforce::get('/endpoint');
} catch (SalesforceException $e) {
    // Handle Salesforce-specific errors
    $details = $e->getDetails(); // Array of error details
    $status = $e->getCode();     // HTTP status code
} catch (RequestException $e) {
    // Handle HTTP client errors
}
```

Testing
-------

[](#testing)

```
composer test
```

Logging
-------

[](#logging)

The package automatically logs all API errors and failed requests. Logs include:

- Request method and URL
- Request data
- Response status and body
- Laravel route information
- Stack trace for debugging

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create your feature branch: `git checkout -b feature/my-new-feature`
3. Commit your changes: `git commit -am 'Add new feature'`
4. Push to the branch: `git push origin feature/my-new-feature`
5. Submit a pull request

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover any security-related issues, please email \[your-email\] instead of using the issue tracker. All security vulnerabilities will be promptly addressed.

Please review [our security policy](../../security/policy) for more information.

Credits
-------

[](#credits)

- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance70

Regular maintenance activity

Popularity34

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 97.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Recently: every ~41 days

Total

13

Last Release

377d ago

Major Versions

0.1.0 → v1.0.02024-11-23

v1.0.0 → v2.0.02025-02-23

v2.0.0 → v3.0.02025-05-07

PHP version history (3 changes)0.0.3PHP ^8.0

0.0.7PHP ^8.2

v3.0.0PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/fdbdc9ea38ded68b1272a7a1b50f517ef856cb7014c760dc092acbc78a151ecd?d=identicon)[antogkou](/maintainers/antogkou)

---

Top Contributors

[![antogkou](https://avatars.githubusercontent.com/u/15363511?v=4)](https://github.com/antogkou "antogkou (37 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laraveloauth2restsalesforce

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/antogkou-laravel-salesforce/health.svg)

```
[![Health](https://phpackages.com/badges/antogkou-laravel-salesforce/health.svg)](https://phpackages.com/packages/antogkou-laravel-salesforce)
```

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
