Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquent Salesforce Objects Laravel Package

daikazu/eloquent-salesforce-objects

Laravel Eloquent-style models for Salesforce sObjects. Query and sync Salesforce data using familiar Eloquent patterns, with object mapping and relationships to work with Accounts, Contacts, and more from your Laravel app.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Leverages Laravel’s Eloquent ORM, enabling developers to use familiar patterns (e.g., Model::all(), Model::find(), relationships) for Salesforce data.
    • Built atop omniphx/forrest, a robust Salesforce API wrapper, ensuring compatibility with Salesforce’s REST API and bulk operations.
    • MIT license allows seamless integration into proprietary or open-source projects.
    • Reduces boilerplate for CRUD operations against Salesforce by abstracting API calls into Eloquent-like syntax.
  • Cons:

    • Tight Coupling to Eloquent: Assumes Laravel’s ORM is already in use. If the stack deviates (e.g., custom query builder, non-Laravel PHP), adoption may require significant refactoring.
    • Salesforce-Specific Constraints: Eloquent’s conventions (e.g., snake_case tables) may clash with Salesforce’s PascalCase object naming and API quirks (e.g., composite keys, custom metadata).
    • Limited Query Builder Support: Complex Salesforce SOQL queries (e.g., subqueries, aggregation) may not map cleanly to Eloquent’s query builder, requiring raw SOQL or custom methods.
    • No Native Support for Bulk API: While forrest supports bulk operations, the Eloquent layer may not expose them intuitively (e.g., no Model::chunk() for Bulk API).

Integration Feasibility

  • High for Laravel Monoliths: Ideal for apps already using Eloquent where Salesforce integration is needed for sync, reporting, or hybrid workflows.
  • Moderate for Microservices: Feasible if the microservice adopts Laravel/Eloquent, but may introduce unnecessary coupling if other frameworks (e.g., Symfony, Node.js) are used elsewhere.
  • Low for Headless/Non-PHP Stacks: Not suitable for frontend frameworks (React, Vue) or non-PHP backends (Go, Python).

Technical Risk

  • Data Model Mismatch: Salesforce objects often lack traditional PK/FK relationships (e.g., polymorphic WhatId fields in Task). Eloquent’s relationship methods (e.g., belongsTo) may need overrides.
  • Performance Overhead: Eloquent’s eager loading (with()) could trigger N+1 queries if not optimized for Salesforce’s API limits (e.g., 200 records per SOQL query).
  • Authentication Complexity: Salesforce auth (OAuth 2.0, JWT) must be configured separately via forrest. Misconfiguration could lead to failed API calls.
  • Schema Drift: Salesforce objects can change dynamically (e.g., custom fields added via UI). The package lacks built-in schema validation or migration tools.
  • Testing Challenges: Mocking Salesforce responses in unit tests requires stubbing forrest or using a local Salesforce sandbox, adding complexity.

Key Questions

  1. Use Case Clarity:

    • Is this for real-time sync (e.g., lead capture), batch processing (e.g., nightly data exports), or hybrid workflows (e.g., triggering Salesforce flows from Laravel)?
    • Will the package replace existing Salesforce SDK usage, or supplement it?
  2. Performance Requirements:

    • What are the expected query volumes and response time SLAs? Bulk API may be needed for high-throughput operations.
    • How will API governor limits (e.g., 15,000 SOQL queries/day) be monitored/managed?
  3. Data Consistency:

    • How will conflicts (e.g., concurrent updates to the same Salesforce record) be handled?
    • Is optimistic/pessimistic locking required (e.g., via LastModifiedDate checks)?
  4. Error Handling:

    • How will Salesforce-specific errors (e.g., INVALID_FIELD, DUPLICATE_VALUE) be translated into Laravel exceptions?
    • Are retry mechanisms needed for transient failures (e.g., throttling)?
  5. Long-Term Maintenance:

    • Who will manage Salesforce schema changes (e.g., deprecated fields, new objects)?
    • Is there a plan for package updates (e.g., if forrest or Laravel/Eloquent evolve)?
  6. Security:

    • How will Salesforce credentials (e.g., consumer_key, private_key) be stored (env vars, Vault)?
    • Are field-level permissions (e.g., Salesforce sharing rules) being considered?
  7. Alternatives:

    • Would a custom wrapper (e.g., using forrest directly) be more flexible for niche use cases?
    • Are there commercial alternatives (e.g., MuleSoft, Salesforce Connect) that offer more features?

Integration Approach

Stack Fit

  • Best Fit:
    • Laravel 8+ with Eloquent ORM.
    • Projects using Taylor Otwell’s laravel-salesforce (if migrating from that package).
    • Apps requiring CRUD-heavy interactions with Salesforce (e.g., syncing User, Account, or custom objects).
  • Partial Fit:
    • Lumen (Laravel micro-framework) with Eloquent.
    • Non-Laravel PHP (e.g., Symfony) if Eloquent’s query builder is replicated.
  • Poor Fit:
    • Headless APIs or frontend frameworks (React, Vue).
    • Non-PHP stacks (Go, Python, Node.js).
    • Highly complex Salesforce workflows (e.g., Apex triggers, platform events) requiring deep Salesforce SDK features.

Migration Path

  1. Assessment Phase:

    • Audit existing Salesforce interactions (e.g., direct REST calls, SOAP, or other PHP SDKs).
    • Map Salesforce objects to Laravel models (e.g., Account → AccountModel).
    • Identify non-CRUD use cases (e.g., bulk operations, metadata API calls) that may require custom code.
  2. Proof of Concept (PoC):

    • Implement a single model (e.g., Lead) using the package.
    • Test basic CRUD, relationships (e.g., Lead::with('Contact')), and error handling.
    • Benchmark performance against direct forrest usage.
  3. Incremental Rollout:

    • Phase 1: Replace simple queries (e.g., Lead::where('status', 'Open')->get()).
    • Phase 2: Migrate complex queries to raw SOQL or custom methods.
    • Phase 3: Adopt for bulk operations (e.g., using forrest’s Bulk API directly).
    • Phase 4: Integrate with Laravel’s events/queues (e.g., Model::saved() → trigger Salesforce flows).
  4. Deprecation Plan:

    • Phase out legacy Salesforce SDK calls in favor of Eloquent models.
    • Document escape hatches for unsupported features (e.g., metadata API).

Compatibility

  • Laravel Version: Tested with Laravel 8+ (check package docs for exact compatibility).
  • PHP Version: Requires PHP 8.0+ (align with Laravel’s requirements).
  • Salesforce API: Relies on forrest’s supported API versions (e.g., REST v56.0). Ensure alignment with your org’s API version.
  • Database: No direct DB dependency, but Eloquent’s query cache may interact with Laravel’s cache drivers.
  • Third-Party Packages:
    • Conflict Risk: If using laravel-salesforce, evaluate duplication of effort.
    • Synergy: Works well with Laravel’s Scout (for search), Nova (admin panel), or Horizon (queues).

Sequencing

  1. Setup:

    • Install package: composer require daikazu/eloquent-salesforce-objects.
    • Configure forrest in .env (e.g., SALESFORCE_CLIENT_ID, SALESFORCE_PRIVATE_KEY).
    • Publish config: php artisan vendor:publish --provider="Daikazu\EloquentSalesforceObjects\ServiceProvider".
  2. Model Definition:

    use Daikazu\EloquentSalesforceObjects\EloquentSalesforceModel;
    
    class Account extends EloquentSalesforceModel
    {
        protected $objectName = 'Account'; // Salesforce API name
        protected $primaryKey = 'Id'; // Salesforce ID field
    }
    
  3. Basic Usage:

    $account = Account::find('001xx000003DGgJAAU');
    $accounts = Account::where('Industry', 'Technology')->get();
    
  4. Relationships:

    class Contact extends EloquentSalesforceModel
    {
        public function account()
        {
            return $this->belongsTo(Account::class, 'AccountId', 'Id');
        }
    }
    
  5. Advanced:

    • Customize queries with raw SOQL:
      $results = Account::query()->soql('SELECT Id,
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package