Weave Code
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

Laravel Shipping Laravel Package

ivanmitrikeski/laravel-shipping

Laravel shipping package with UPS, FedEx, Canada Post, Purolator, and USPS v3 support. Get rates and create shipments via REST/OAuth APIs, with sandbox mode and flat-rate options (boxes/prices) via Eloquent models. Usable outside Laravel, too.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Modularity: The package aligns well with Laravel’s Eloquent ORM and service container, enabling clean separation of shipping logic from business logic. The provider-agnostic design (via abstract ShippingProvider class) allows for easy extension or swapping of carriers.
  • Domain-Specific Models: Eloquent models (Shipment, Rate, Address, etc.) fit naturally into Laravel’s MVC structure, reducing boilerplate for shipping-related CRUD operations.
  • API Abstraction: The package abstracts OAuth/REST complexity for UPS, FedEx, etc., which is critical for e-commerce platforms with multi-carrier needs.

Integration Feasibility

  • Laravel-Centric: Designed for Laravel (e.g., service providers, Facades, migrations), minimizing friction for adoption. Non-Laravel usage is possible but secondary.
  • Dependency Clarity: Explicit .env requirements for credentials and sandbox mode simplify configuration. However, sensitive data management (e.g., rotation, encryption) must be handled externally.
  • API Coverage: Supports core shipping workflows (rate calculation, shipment creation), but lacks advanced features like tracking updates or labels (beyond USPS).

Technical Risk

  • Provider-Specific Quirks: Each carrier’s API has edge cases (e.g., UPS’s Shipment API vs. FedEx’s CreateShipment). The package mitigates this via provider-specific classes, but custom logic may still be needed.
  • Rate Limiting/Throttling: No built-in retry logic for API rate limits. Requires middleware or application-level handling (e.g., Laravel’s retry helper).
  • Data Validation: Relies on Laravel’s validation, but complex carrier-specific rules (e.g., Purolator’s billing account formats) may need manual validation layers.
  • Testing: Limited test coverage in the package (per repository maturity). Integration tests for all providers should be prioritized.

Key Questions

  1. Carrier Prioritization: Which providers are critical for MVP vs. future phases? (e.g., USPS-only may simplify initial integration.)
  2. Authentication Flow: How will credentials be managed (e.g., Vault, encrypted .env, or a secrets manager)?
  3. Error Handling: What’s the acceptable UX for API failures (e.g., retries, fallback carriers, or user notifications)?
  4. Extensibility: Are there plans to support additional providers (e.g., DHL, Amazon Shipping) or features (e.g., tracking, labels)?
  5. Performance: Will rate calculations be cached (e.g., Redis), and how will stale data be handled?
  6. Compliance: Are there regional restrictions (e.g., Canada Post for Canadian orders only) that require logic branching?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Ideal for Laravel apps using Eloquent, Queues, and API clients (e.g., Guzzle). Compatible with:
    • Frontend: Livewire/Inertia for real-time rate updates.
    • Backend: Queues for async shipment creation (e.g., dispatch(new CreateShipmentJob($data))).
    • Testing: Pest/Laravel’s HTTP tests for API provider mocking.
  • Non-Laravel: Possible but requires manual setup (e.g., instantiating ShippingProvider directly). Not recommended for greenfield projects.

Migration Path

  1. Phase 1: Sandbox Setup
    • Configure .env with sandbox credentials for all target providers.
    • Test rate calculations and shipment creation in a staging environment.
  2. Phase 2: Production Rollout
    • Replace sandbox credentials with live ones in a feature flagged branch.
    • Implement monitoring for API failures (e.g., Sentry, Laravel Horizon).
  3. Phase 3: Feature Expansion
    • Add carrier-specific logic (e.g., Purolator’s registered account validation).
    • Integrate with order workflows (e.g., trigger shipment creation post-payment).

Compatibility

  • Laravel Version: Tested with Laravel 10+ (per last release date). Verify compatibility with your version.
  • PHP Version: Requires PHP 8.1+. Check for deprecated functions if using older versions.
  • Database: Uses Eloquent, so any Laravel-supported DB (MySQL, PostgreSQL, etc.) works. Migrations are provider-agnostic.
  • Third-Party Conflicts: Potential naming collisions with existing Shipping classes or Facades. Use aliases if needed.

Sequencing

  1. Prerequisites:
    • Laravel app with Eloquent and API client (Guzzle) configured.
    • Database migrations run (php artisan migrate).
  2. Core Integration:
    • Publish package config (php artisan vendor:publish --provider="IvanMitrikeski\Shipping\ShippingServiceProvider").
    • Bind providers to the container (e.g., config(['shipping.providers.ups' => UpsProvider::class])).
  3. Workflow Integration:
    • Hook into order creation (e.g., OrderCreated event → calculate rates).
    • Add shipping rate selection to checkout (e.g., Livewire component).
  4. Post-Launch:
    • Implement webhooks for shipment updates (if providers support it).
    • Add analytics for carrier performance (e.g., cost, success rates).

Operational Impact

Maintenance

  • Updates: MIT license allows forks. Monitor for provider API changes (e.g., UPS deprecating endpoints). Plan for:
    • Dependency updates (composer update ivanmitrikeski/laravel-shipping).
    • Backward-compatibility breaks (e.g., renamed provider methods).
  • Credential Rotation: Automate .env updates for provider credentials (e.g., using Laravel Forge or a secrets manager).
  • Deprecation: USPS API v3 is stable, but other providers may sunset endpoints. Subscribe to carrier changelogs.

Support

  • Debugging: Use SHIPPING_SANDBOX=true for local testing. Log provider responses for troubleshooting:
    $provider->setDebug(true);
    
  • Provider-Specific Issues:
    • UPS/FedEx: OAuth token expiration handling (e.g., refresh tokens).
    • Canada Post: Customer number validation errors.
    • USPS: Address validation failures (may require external tools like SmartyStreets).
  • Community: Limited stars/support. Plan for internal documentation or extended SLAs for critical providers.

Scaling

  • Rate Limiting: Implement exponential backoff for API calls (e.g., using spatie/fork).
  • Concurrency: Use Laravel Queues for async shipment creation to avoid timeouts:
    CreateShipment::dispatch($shipmentData)->onQueue('shipping');
    
  • Caching: Cache rate responses (e.g., 5-minute TTL) for frequent queries:
    $rates = Cache::remember("rates_{$origin}_{$destination}", now()->addMinutes(5), fn() =>
        $provider->getRates($origin, $destination)
    );
    
  • Database: Optimize shipments table for read-heavy workloads (e.g., add indexes for status, carrier).

Failure Modes

Failure Scenario Impact Mitigation
Provider API downtime Orders stuck in checkout Fallback to a secondary carrier or manual override.
Invalid credentials All requests fail Automated alerting (e.g., Laravel Healthcheck).
Rate calculation timeouts Poor UX during checkout Queue requests and notify user via email.
Carrier-specific validation errors Failed shipments Pre-validate addresses/carrier rules.
Database connection issues Lost shipment records Use transactions and retry logic.

Ramp-Up

  • Onboarding Time: 2–4 weeks for a Laravel dev to integrate core providers (excluding custom logic).
  • Training Needs:
    • Developers: Focus on provider-specific quirks (e.g., FedEx’s Shipment API vs. UPS).
    • QA: Test edge cases (e.g., international addresses, weight limits).
    • Ops: Understand credential rotation and monitoring setup.
  • Documentation Gaps: Supplement the README with:
    • Example workflows (e.g., "How to add a new carrier").
    • Troubleshooting guides for common errors (e.g., Purolator’s 403 Forbidden).
  • Tooling: Recommend:
    • Postman collections for provider API testing.
    • Laravel Telescope for debugging requests.
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.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle