- How do I generate a boarding pass or event ticket using this package in Laravel?
- Use the `MobilePass` model and builder classes like `BoardingPassBuilder` or `EventTicketBuilder`. Define pass details (e.g., title, expiry, barcodes) via Eloquent, then call `generate()` to create the pass file. The package handles Apple Wallet (.pkpass) and Google Wallet formats automatically. Example: `$pass = MobilePass::createBoardingPass($data)->generate();`
- What Laravel versions does spatie/laravel-mobile-pass support?
- The package is fully compatible with Laravel 8.x and 9.x (tested up to v1.2.1). It requires PHP 8.0+ due to Laravel’s dependency on newer PHP features. Check the [UPGRADING.md](https://github.com/spatie/laravel-mobile-pass/blob/main/UPGRADING.md) guide for migration notes if upgrading from older versions.
- Do I need HTTPS for Apple Wallet passes? What if my Laravel app isn’t on HTTPS yet?
- Yes, Apple Wallet **mandates HTTPS** for all web service URLs. If your Laravel app isn’t HTTPS-compliant, you’ll need to configure SSL certificates (e.g., via Let’s Encrypt) or use a load balancer with HTTPS termination. The package includes automated validation to enforce this requirement during pass generation.
- How do I push updates to a user’s installed pass (e.g., for ticket validation or expiry changes)?
- Use the `pushUpdate()` method on a `MobilePass` instance. The package queues a `PushPassUpdateJob` to handle async updates via Laravel’s queue system. For Apple Wallet, it signs and delivers updates via the `.webp` endpoint; for Google Wallet, it triggers a callback verification flow. Example: `$pass->pushUpdate();`
- Can I customize the database schema for MobilePass? What fields are required?
- The package provides a default migration, but you can extend it via the `mobile-pass.models.mobile_pass` config key. Required fields include `pass_serial` (unique identifier), `format` (Apple/Google), and `data` (serialized pass JSON). Custom fields (e.g., `nfc_data`) can be added by publishing and modifying the migration.
- What are the Google Wallet API requirements? Do I need a Google Cloud project?
- Yes, Google Wallet requires a **Google Cloud project** with the Wallet API enabled and OAuth credentials configured. You’ll need to set up a **service account** and provide the JSON key file path in Laravel’s config. The package uses `ECv2SigningOnly` for callback verification, which may introduce minor latency but is handled automatically.
- How do I handle images for passes (e.g., logos, barcodes)? Can I use remote URLs?
- Images can be hosted remotely (e.g., AWS S3, CDN) or locally. Since v1.1, the package supports remote image URLs, but you must ensure they’re HTTPS-compliant. For local storage, use Laravel’s `Storage` facade to generate signed URLs or configure a storage link. Example: `$pass->setImageUrl(storage_path('app/pass-logo.png'));`
- Are there performance considerations for high-volume pass generation (e.g., 10,000+ passes/day)?
- Generating `.pkpass` files can be resource-intensive due to certificate signing. For high volumes, **queue the `generate()` calls** and consider **offloading to a worker queue** (e.g., Redis, database). Test under load, especially for Apple Wallet passes, as their signing process is more CPU-heavy than Google Wallet.
- What alternatives exist for Laravel mobile pass generation? Should I use this package or another?
- Alternatives include **custom PKPassKit (Apple) + Google Wallet API** implementations or third-party services like **PassKit.io** or **Ticketmaster’s API**. However, `spatie/laravel-mobile-pass` is the most **Laravel-native** solution, offering built-in Eloquent integration, queue support, and unified updates. It’s ideal if you need deep Laravel ecosystem compatibility.
- How do I test pass generation and updates in a CI/CD pipeline? Does the package support testing?
- The package includes **mockable services** for testing. Use `MobilePass::fake()` to simulate pass generation without real certificates. For update testing, mock the queue and verify job execution. Example: `MobilePass::fake()->assertGenerated($pass);`. The package’s test suite (PHPUnit) covers core functionality, and you can extend it with feature tests for your specific pass types.