Wallet
Raxos Wallet is a focused PHP library for generating Apple Wallet (.pkpass) passes. It models the PassKit JSON schema as strongly typed, readonly value objects (Pass, the style containers, field content, barcodes, locations and more), packages them into a signed zip archive, and exposes ready to send HTTP responses. It builds on raxos/foundation for temporary files and color utilities, and on raxos/http for response objects.
The pass model mirrors Apple's pass.json schema closely, so if you know the PassKit fields you already know the constructor parameters. PKPass handles adding assets, signing the manifest with an issuer certificate through OpenSSL, and producing a downloadable response. PKPassBundle groups multiple signed passes into a single .pkpasses archive.
Apple only
The package description mentions both Apple Wallet and Google Wallet, but only the Apple implementation exists today. Everything in this package lives under the Raxos\Wallet\Apple namespace, apart from the shared Color value object.
Highlights
PassThe readonly value object that models the full pass.json document.PKPassAdd assets, sign the manifest and produce a signed .pkpass archive.PKPassBundleGroup multiple signed passes into a single .pkpasses bundle.IdentityCarry the certificate, private key and identifiers used to sign a pass.BarcodeAttach an Aztec, Code128, PDF417 or QR barcode to a pass.ColorAn RGB color value object with hex and rgb() conversion helpers.Explore by category
- Building a pass: the
Passvalue object and the five style containers (Generic, StoreCard, Coupon, EventTicket, BoardingPass). - Fields, barcodes and components: field content, barcodes, colors, locations, beacons, NFC, relevant dates and the enums that constrain their values.
- Signing and packaging: the
PKPasslifecycle, from adding assets to signing the manifest and closing the archive. - Bundles and localization: group passes with
PKPassBundleand add localized.stringsfiles.
Quick example
<?php
declare(strict_types=1);
use Raxos\Wallet\Apple\{Identity, PKPass};
use Raxos\Wallet\Apple\Component\{Barcode, EventTicket, Pass, PrimaryField};
use Raxos\Wallet\Apple\Enum\BarcodeFormat;
use Raxos\Wallet\Component\Color;
$identity = new Identity(
certificate: file_get_contents(__DIR__ . '/certificate.pem'),
privateKey: file_get_contents(__DIR__ . '/private-key.pem'),
password: 'secret',
passTypeIdentifier: 'pass.dev.example.ticket',
teamIdentifier: 'ABCDE12345'
);
$pass = new Pass(
description: 'Concert ticket',
organizationName: 'Example Venue',
serialNumber: 'TCK-00042',
backgroundColor: Color::fromHex('#1c1c1e'),
barcodes: [
new Barcode(format: BarcodeFormat::QR, message: 'TCK-00042')
],
eventTicket: new EventTicket(
primaryFields: [
new PrimaryField(key: 'event-name', value: 'Summer Nights', label: 'Event')
]
)
);
$pkpass = new PKPass($identity, $pass);
$pkpass->file('icon.png', __DIR__ . '/assets/icon.png');
$pkpass->sign();
$pkpass->close();
return $pkpass->respond();Installation
Install the package with Composer. See installation for the required PHP version, extensions and the WWDR certificate needed for signing.
composer require raxos/wallet