spatie/laravel-mobile-pass
Laravel package to generate Apple Wallet mobile passes (boarding passes, tickets, coupons, cards) with support for pushing updates to issued passes so they stay current on users’ devices. In development—don’t use in production yet.
Pros:
Cons:
Laravel Compatibility:
Pass, PassUpdate).sync, database, or redis drivers).Third-Party Dependencies:
spatie/laravel-barcode (dependency not listed but implied by examples).Data Flow:
[User Request] → [Laravel Controller] → [Queue Job] → [Pass Service] → [Apple/Google API] → [Mobile Device]
Updates follow a similar path with webhook validation (e.g., verifying Apple’s push notification signatures).
| Risk Area | Description | Mitigation Strategy |
|---|---|---|
| API Rate Limits | Apple/Google may throttle requests during peak loads (e.g., event ticket generation). | Implement exponential backoff in queue workers and monitor API usage. |
| Pass Validation | Apple/Google may reject malformed passes (e.g., invalid JSON-LD, missing fields). | Unit test pass generation with validation tools like Apple’s PassKit Validator. |
| Queue Failures | Async jobs may fail silently (e.g., API timeouts, database locks). | Add dead-letter queues and retry logic with exponential backoff. |
| CORS/HTTPS | Mobile devices require HTTPS and proper CORS headers for pass delivery. | Ensure your Laravel app is HTTPS-only and configure CORS middleware (e.g., fruitcake/laravel-cors). |
| User Privacy | Passes may contain PII (e.g., names, emails). | Anonymize data where possible; comply with GDPR/CCPA via data encryption. |
| Fallback Mechanisms | No offline generation or SMS/email fallback for unsupported devices. | Document limitations in UX; consider hybrid delivery (e.g., QR codes for non-Wallet users). |
Laravel Core:
Pass, PassUpdate) with relationships to users/events.PassGenerateJob, PassUpdateJob).PassGenerated, PassUpdated events for analytics or notifications.ValidateApplePassSignature).Dependencies:
| Dependency | Purpose | Version Check |
|---|---|---|
spatie/laravel-barcode |
Generate barcodes/QRs for passes. | v10.x |
guzzlehttp/guzzle |
HTTP client for Apple/Google APIs. | ^7.0 |
spatie/array-to-object |
Convert JSON-LD to PHP objects for pass templates. | ^4.0 |
laravel/framework |
Core Laravel (test compatibility with your version). | 10.x |
Database Schema:
// Example Pass Model
Schema::create('passes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained();
$table->string('type'); // 'boarding_pass', 'event_ticket', etc.
$table->json('metadata'); // Dynamic fields (e.g., flight details)
$table->string('serial_number')->unique(); // Required by Apple/Google
$table->timestamps();
});
Pre-Integration:
spatie/laravel-barcode).Package Installation:
composer require spatie/laravel-mobile-pass
php artisan vendor:publish --provider="Spatie\MobilePass\MobilePassServiceProvider"
config/mobile-pass.php) for API keys and pass types.Model Setup:
Spatie\MobilePass\Pass or create a custom model:
use Spatie\MobilePass\Pass as BasePass;
class BoardingPass extends BasePass {
protected $type = 'boarding-pass';
protected $logoUrl = 'https://example.com/logo.png';
}
Pass Generation:
PassGenerator facade:
use Spatie\MobilePass\Facades\PassGenerator;
$pass = PassGenerator::create(BoardingPass::class, [
'flightNumber' => 'AA123',
'departure' => 'JFK',
]);
dispatch(new GeneratePassJob($pass));
Update Handling:
PassUpdater:
PassUpdater::update($pass, ['status' => 'boarded']);
Webhook Validation:
Route::post('/apple-pass-updates', [ApplePassUpdateHandler::class, 'handle']);
dom, fileinfo, mbstring (required for JSON-LD and barcode generation).| Phase | Tasks | Dependencies |
|---|
How can I help you explore Laravel packages today?