PHP code example of laulamanapps / apple-passbook-laravel
1. Go to this page and download the library: Download laulamanapps/apple-passbook-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laulamanapps / apple-passbook-laravel example snippets
namespace App\Http\Controllers;
use LauLamanApps\ApplePassbook\Build\Compiler;
use LauLamanApps\ApplePassbook\GenericPassbook;
use LauLamanApps\ApplePassbook\MetaData\Barcode;
use LauLamanApps\ApplePassbook\Style\BarcodeFormat;
final class PassbookController
{
public function __construct(
private readonly Compiler $compiler,
) {
}
public function download()
{
$passbook = new GenericPassbook('8j23fm3');
$passbook->setTeamIdentifier('<TeamId>');
$passbook->setPassTypeIdentifier('<PassTypeId>');
$passbook->setOrganizationName('Toy Town');
$passbook->setDescription('Toy Town Membership');
$barcode = new Barcode();
$barcode->setFormat(BarcodeFormat::Pdf417);
$barcode->setMessage('123456789');
$passbook->setBarcode($barcode);
return response($this->compiler->compile($passbook), 200, [
'Content-Description' => 'File Transfer',
'Content-Type' => 'application/vnd.apple.pkpass',
'Content-Disposition' => 'filename="passbook.pkpass"',
]);
}
}