承接 robertogallea/laravel-greenpass 相关项目开发

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

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

robertogallea/laravel-greenpass

Composer 安装命令:

composer require robertogallea/laravel-greenpass

包简介

European green-pass decoding and validation for php/laravel

README 文档

README

Laravel Green Pass

laravel-greenpass

Author GitHub release (latest SemVer) Laravel >=6.0 Software License PSR2 Conformance Sponsor me! Packagist Downloads

laravel-greenpass is a package for the management of the European Green Pass (i.e. covid certification). The package allows easy validation and decoding of the GreenPass. It is also suited for Laravel since it provides a convenient custom validator for request validation.

Installation

Run the following command to install the latest applicable version of the package:

composer require robertogallea/laravel-greenpass

Laravel

In your app config, add the Service Provider to the $providers array (only for Laravel 5.4 or below):

'providers' => [
   ...
   robertogallea\LaravelGreenPass\GreenPassServiceProvider::class,
],

Lumen

In bootstrap/app.php, register the Service Provider

$app->register(robertogallea\LaravelGreenPass\GreenPassServiceProvider::class);

Configuration

By default, the underlying validation package saves the validation certificates inside storage/app/public/green_pass_cache. If you want to change this folder, publish the config file with the command

php artisan vendor:publish --provider="robertogallea\LaravelGreenPass\GreenPassServiceProvider" --tag="config"

and edit the certificate-storage-path key inside the config/green-pass.php file.

Make sure the chosen folder has write access!

Validation

To validate the formal correctness of a green pass, use the greenpass and greenpass_file keyword in your validation rules array. Please note that in this way you don't check that the green pass is actually valid (i.e. not expired or revoked).

    public function rules()
    {
        return [
            'greenpass_string' => 'greenpass',
            
            //...
        ];
    }
    public function rules()
    {
        return [
            'greenpass_uploaded_file' => 'greenpass_file',
            
            //...
        ];
    }

To perform strict validation (i.e. check actual validity) you can add the active parameter to the validator rule:

    public function rules()
    {
        return [
            'greenpass_string' => 'greenpass:active',
            
            //...
        ];
    }
    public function rules()
    {
        return [
            'greenpass_uploaded_file' => 'greenpass_file:active',
            
            //...
        ];
    }

Utility GreenPassDecoder class

A green pass can be read using the GreenPassDecoder service:

use robertogallea\LaravelGreenPass\GreenPassDecoder;

...

$greenpass = new GreenPassDecoder();

$result = $greenpass->decode('HC1:...');
var_dump($result);

// or

$result = $greenpass->decodeFile('/path/to/file');
var_dump($result);

You can also use the GreenPass facade:

use robertogallea\LaravelGreenPass\GreenPassDecoder;

...
$result = \GreenPass::decode('HC1:...');
var_dump($result);

// or

$result = \GreenPass::decodeFile('/path/to/file');
var_dump($result);

统计信息

  • 总下载量: 167
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2021-10-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固