1. Go to this page and download the library: Download antogkou/laravel-salesforce library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
antogkou / laravel-salesforce example snippets
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('[email protected]')
->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
use Antogkou\LaravelSalesforce\Facades\Salesforce;
// Basic request
$response = Salesforce::get('/endpoint');
// With custom user context
$response = Salesforce::setEmail('[email protected]')
->get('/endpoint');
// With custom headers
$response = Salesforce::post('/endpoint', $data, [
'Custom-Header' => 'Value'
]);
// Set custom user email for the request
$response = Salesforce::setEmail('[email protected]')
->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');
}