PHP Passkit class for iOS Wallet
This class provides the functionality to create a pass for Wallet in Apple's iOS 6 and newer on-the-fly. It creates, signs and packages the Pass as a .pkpass file according to Apple's documentation.
- PHP 5.4 or higher
- PHP ZIP Support (may be installed by default)
- Access to filesystem (script must be able to create temporary folders)
$ composer require pkpass/pkpass
or add to your composer.json:
Require PKPass.php file in your php files
Please take a look at the example.php file for example usage. For more info on the JSON for the pass and how to style it, take a look at the docs at developers.apple.com.
Requesting the Pass Certificate
- Go to the iOS Provisioning portal.
- Create a new Pass Type ID, and write down the Pass ID you choose, you'll need it later.
- Click the edit button under your newly created Pass Type ID and generate a certificate according to the instructions shown on the page.
- Download the .cer file and drag it into Keychain Access.
- Find the certificate you just imported and click the triangle on the left to reveal the private key.
- Select both the certificate and the private key under it, then right click the certificate in Keychain Access and choose
Export 2 items….
- Choose a password and export the file to a folder.
Getting the example.php sample to work
- Request the Pass certificate (
.p12) as described above and upload it to your server.
- Set the correct path and password on line 22.
- Change the
teamIndentifierto the correct values on lines 29 and 31 (
teamIndentifiercan be found on the Developer Portal).
After completing these steps, you should be ready to go. Upload all the files to your server and navigate to the address of the examples/example.php file on your iPhone.
If you aren't able to open your pass on an iPhone, plug the iPhone into a Mac and open the 'Console' application. On the left, you can select your iPhone. You will then be able to inspect any errors that occur while adding the pass:
Support & documentation
Please read the instructions above and consult the Passbook Documentation before submitting tickets or requesting support. It might also be worth to check Stackoverflow, which contains quite a few questions about this library.
Email me at thomas [at] scholica.com or tweet me @tschoffelen.