定制 robertsaupe/php-phar-selfupdate 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

robertsaupe/php-phar-selfupdate

Composer 安装命令:

composer require robertsaupe/php-phar-selfupdate

包简介

php library for phar selfupdate with a manifest file

README 文档

README

Minimum PHP version: 8.2 Packagist Version Packagist Downloads License

php library for phar selfupdate with a manifest file

Supporting

GitHub | Patreon | PayPal | Amazon

Installing

composer require robertsaupe/php-phar-selfupdate

Getting started

Update

use Exception;
use robertsaupe\Phar\SelfUpdate\ManifestUpdate;

$updater = new ManifestUpdate('1.0.0', 'path_to_manifest.json');

try {
    $result = $updater->update();
    $newVersion = $updater->getNewVersion();
    $oldVersion = $updater->getOldVersion();
    if ($result) {
        print('Phar has been updated.'.PHP_EOL);
        print('Current version is: '.$newVersion.PHP_EOL);
        print('Previous version was: '.$oldVersion.PHP_EOL);
    } else {
        print('Phar is currently up to date.'.PHP_EOL);
        print('Current version is: '.$oldVersion.PHP_EOL);
    }
} catch (Exception $e) {
    print('Error: '.$e->getMessage().PHP_EOL);
}

Update-Check

use Exception;
use robertsaupe\Phar\SelfUpdate\ManifestUpdate;

$updater = new ManifestUpdate('1.0.0', 'path_to_manifest.json');

print('The current local version is: '.$updater->getCurrentLocalVersion().PHP_EOL);

try {
    $result = $updater->getCurrentRemoteVersion();
    if ($result) {
        print('The current '.$updater->getStability().' build available remotely is: '.$result.PHP_EOL);
    } else {
        print('You have the current '.$updater->getStability().' build installed.'.PHP_EOL);
    }
} catch (Exception $e) {
    print('Error: '.$e->getMessage().PHP_EOL);
}

Rollback

use Exception;
use robertsaupe\Phar\SelfUpdate\ManifestUpdate;

$updater = new ManifestUpdate('1.0.0', 'path_to_manifest.json');

try {
    $result = $updater->rollback();
    if ($result) {
        print('Phar has been rolled back to prior version.'.PHP_EOL);
    } else {
        print('Rollback failed for reasons unknown.'.PHP_EOL);
    }
} catch (Exception $e) {
    print('Error: '.$e->getMessage().PHP_EOL);
}

manifest.json

{
  "1.0.1": {
    "version": "1.0.1",
    "url": "url_or_path_to\/1.0.1\/file.phar",
    "sha1": "4f0dcc31a49417ee459abe5e73216f84a131fef3",
    "sha256": "2e82de11605f73732ddf0948a6c2b7235cb139bb974c1ab88b1b5dc21fcb571f",
    "sha512": "b356751b07e4626e043f65aeb85bf00b5a9933142652a17122abff0d43db3ce1371f212525b6aac011aa096592a5bcc85f14659fc2cd541f31ec2f4089931e91"
  },
  "1.0.0": {
    "version": "1.0.0",
    "url": "url_or_path_to\/1.0.0\/file.phar",
    "sha1": "95743c0d18bde06ee15878092dd2edbe6f1d2e76",
    "sha256": "5555f3d1f0567909e07bfc7cda29383cd63d9ad3d76aac88f43509904d916c23",
    "sha512": "c9bf8e3712cb913dc067533909117ad17722ef6b4c869e47c1ce8c56cda2a1d182657063eaa713cca331584f2ac548465e87d88895779b4da0b52c62b9f70a2a"
  }
}

HashAlgo

Bash

sha1sum file.phar
sha256sum file.phar
sha512sum file.phar

PHP

$sha1 = hash_file('sha1', 'file.phar');
$sha256 = hash_file('256', 'file.phar');
$sha512 = hash_file('512', 'file.phar');

Credits

robertsaupe/php-phar-selfupdate 适用场景与选型建议

robertsaupe/php-phar-selfupdate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 05 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 robertsaupe/php-phar-selfupdate 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-30