承接 eo/passbook 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eo/passbook

Composer 安装命令:

composer require eo/passbook

包简介

iOS Passbook for PHP

README 文档

README

Code Coverage Scrutinizer Code Quality PHPUnit Total Downloads Latest Stable Version

What is Passbook?

Passbook is an application in iOS that allows users to store coupons, boarding passes, event tickets, store cards, 'generic' cards and other forms of mobile payment.

What does this library do?

PHP-Passbook is a library for creating and packaging passes inside your application. Distribution of generated pass files can be done by attaching the file in an e-mail or serving it from your web server.

Breaking changes

Version 3.0.0

  • Requires PHP >= 7.4

Version 2.0.0

  • Image class setRetina/isRetina methods replaced with setDensity/getDensity.

Installing

Using Composer

To add PHP-Passbook as a local, per-project dependency to your project, simply add a dependency on eo/passbook to your project's composer.json file. Here is a minimal example of a composer.json file that just defines a development-time dependency on the latest version of the library:

{
    "require": {
        "eo/passbook": "dev-master"
    }
}

API Doc

Search by class, method name, or package: http://eymengunay.github.io/php-passbook/api

Usage Example

This example will create a pass of type Ticket and will save the pkpass file in the output path specified. To use this example, you will need to do the following and set the constants accordingly:

<?php

use Passbook\Pass\Field;
use Passbook\Pass\Image;
use Passbook\PassFactory;
use Passbook\Pass\Barcode;
use Passbook\Pass\Structure;
use Passbook\Type\EventTicket;

// Set these constants with your values
define('P12_FILE', '/path/to/p12/certificate.p12');
define('P12_PASSWORD', 'password_for_p12_file');
define('WWDR_FILE', '/path/to/wwdr.pem');
define('PASS_TYPE_IDENTIFIER', 'pass.com.example.yourpass');
define('TEAM_IDENTIFIER', 'IDFROMAPPLE');
define('ORGANIZATION_NAME', 'Your Organization Name');
define('OUTPUT_PATH', '/path/to/output/path');
define('ICON_FILE', '/path/to/icon.png');

// Create an event ticket
$pass = new EventTicket("1234567890", "The Beat Goes On");
$pass->setBackgroundColor('rgb(60, 65, 76)');
$pass->setLogoText('Apple Inc.');

// Create pass structure
$structure = new Structure();

// Add primary field
$primary = new Field('event', 'The Beat Goes On');
$primary->setLabel('Event');
$structure->addPrimaryField($primary);

// Add secondary field
$secondary = new Field('location', 'Moscone West');
$secondary->setLabel('Location');
$structure->addSecondaryField($secondary);

// Add auxiliary field
$auxiliary = new Field('datetime', '2013-04-15 @10:25');
$auxiliary->setLabel('Date & Time');
$structure->addAuxiliaryField($auxiliary);

// Add icon image
$icon = new Image(ICON_FILE, 'icon');
$pass->addImage($icon);

// Set pass structure
$pass->setStructure($structure);

// Add barcode
$barcode = new Barcode(Barcode::TYPE_QR, 'barcodeMessage');
$pass->setBarcode($barcode);

// Create pass factory instance
$factory = new PassFactory(PASS_TYPE_IDENTIFIER, TEAM_IDENTIFIER, ORGANIZATION_NAME, P12_FILE, P12_PASSWORD, WWDR_FILE);
$factory->setOutputPath(OUTPUT_PATH);
$factory->package($pass);

Requirements

Version 1.2.0 is the last release to support PHP 5.3.

Obtaining the Pass Type Identifier and Team ID

You can find more information from Apple on Setting the Pass Type Identifier and Team ID.

Requesting Certificates

P12 Certificate

Once you have downloaded the Apple iPhone certificate from Apple, export it to the P12 certificate format.

To do this on Mac OS:

  1. Open the Keychain Access application (in the Applications/Utilities folder).
  2. If you have not already added the certificate to Keychain, select File > Import. Then navigate to the certificate file (the .cer file) you obtained from Apple.
  3. Select the Keys category in Keychain Access.
  4. Select the private key associated with your iPhone Development Certificate. The private key is identified by the iPhone Developer: public certificate that is paired with it.
  5. Select File > Export Items.
  6. Save your key in the Personal Information Exchange (.p12) file format.
  7. You will be prompted to create a password that is used when you attempt to import this key on another computer.

on Windows:

  1. Convert the developer certificate file you receive from Apple into a PEM certificate file. Run the following command-line statement from the OpenSSL bin directory:
openssl x509 -in developer_identity.cer -inform DER -out developer_identity.pem -outform PEM
  1. If you are using the private key from the keychain on a Mac computer, convert it into a PEM key:
openssl pkcs12 -nocerts -in mykey.p12 -out mykey.pem
  1. You can now generate a valid P12 file, based on the key and the PEM version of the iPhone developer certificate:
openssl pkcs12 -export -inkey mykey.key -in developer_identity.pem -out iphone_dev.p12

If you are using a key from the Mac OS keychain, use the PEM version you generated in the previous step. Otherwise, use the OpenSSL key you generated earlier (on Windows).

WWDR Certificate

Apple’s World Wide Developer Relations (WWDR) certificate is available from Apple at http://developer.apple.com/certificationauthority/AppleWWDRCA.cer. You will have to add this to your Keychain Access and export it in .pem format to use it with the library. The WWDR certificate links your development certificate to Apple, completing the trust chain for your application.

Running Tests

Before submitting a patch for inclusion, you need to run the test suite to check that you have not broken anything.

To run the test suite, install PHPUnit 3.7 (or later) first.

Dependencies

To run the entire test suite, including tests that depend on external dependencies, php-passbook needs to be able to autoload them. By default, they are autoloaded from vendor/ under the main root directory (see vendor/autoload.php).

To install them all, use Composer:

Step 1: Get Composer

curl -s http://getcomposer.org/installer | php

Make sure you download composer.phar in the same folder where the composer.json file is located.

Step 2: Install vendors

php composer.phar install

Note that the script takes some time to finish.

Running

First, install the vendors (see above).

Then, run the test suite from the package root directory with the following command:

phpunit

The output should display OK. If not, you need to figure out what's going on and if the tests are broken because of your modifications.

Reporting an issue or a feature request

Issues and feature requests related to this library are tracked in the Github issue tracker: https://github.com/eymengunay/php-passbook/issues

Contributing

Contributions are welcome and will be fully credited. We accept contributions via Pull Requests here on GitHub.

Please note that this project adhered to PSR-12 Extended Coding Style Guide, so your changes need to:

  • Have PHPUnit-test coverage and tests must pass with all supported PHP versions
  • Pass PHPStan & PHP_CodeSniffer static analysis checks
  • Be documented in README.md for any change in behaviour

Donating

If you want to support the project, please consider to donate a small amount using GitHub Sponsors button. Thank you for your support!

See also

PassbookBundle: PHP-Passbook library integration for Symfony2

eo/passbook 适用场景与选型建议

eo/passbook 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.65M 次下载、GitHub Stars 达 265, 最近一次更新时间为 2013 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mobile」 「ios」 「passbook」 「pass」 「wallet」 「coupons」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 eo/passbook 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 eo/passbook 我们能提供哪些服务?
定制开发 / 二次开发

基于 eo/passbook 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.65M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 268
  • 点击次数: 33
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 265
  • Watchers: 23
  • Forks: 53
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-03-04