承接 hnhdigital-os/laravel-console-self-update 相关项目开发

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

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

hnhdigital-os/laravel-console-self-update

Composer 安装命令:

composer create-project hnhdigital-os/laravel-console-self-update

包简介

Provides a trait to use to self-update console binary.

README 文档

README

              .__   _____                          .___       __          
  ______ ____ |  |_/ ____\         __ ________   __| _/____ _/  |_  ____  
 /  ___// __ \|  |\   __\  ______ |  |  \____ \ / __ |\__  \\   __\/ __ \ 
 \___ \\  ___/|  |_|  |   /_____/ |  |  /  |_> > /_/ | / __ \|  | \  ___/ 
/____  >\___  >____/__|           |____/|   __/\____ |(____  /__|  \___  >
     \/     \/                          |__|        \/     \/          \/ 

Provides a trait to provide self-updating for Laravel Zero console applications.

Latest Stable Version License: MIT Donate to this project using Patreon

Build Status StyleCI Test Coverage Issue Count Code Climate

This package has been developed by H&H|Digital, an Australian botique developer. Visit us at hnh.digital.

Requirements

  • PHP 7.1.3
  • Laravel Zero 5.7

Installation

composer require hnhdigital-os/laravel-console-self-update

Implementation

This package is implemented through a trait and an interface (for the constants).

The basic implementation requires setting a base URL setUrl or providing a flysystem adapter setFlysystem before calling the runSelfUpdate method.

Binary versioning is implemented using BRANCH-TAG (eg stable-1.00) but will fallback to TAG (1.0.0) for the more common Laravel Zero version approach.

<?php

namespace App\Commands;

use HnhDigital\LaravelConsoleSelfUpdate\SelfUpdateInterface;
use HnhDigital\LaravelConsoleSelfUpdate\SelfUpdateTrait;
use LaravelZero\Framework\Commands\Command;

class SelfUpdateCommand extends Command implements SelfUpdateInterface
{
    use SelfUpdateTrait;

    /**
     * The signature of the command.
     *
     * @var string
     */
    protected $signature = 'self-update
                            {--tag=0 : Set a specific tag to install}
                            {--check-version : Return the version of this current binary}';

    /**
     * The description of the command.
     *
     * @var string
     */
    protected $description = 'Self-update this binary';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->setUrl('https://example.com');
        $this->runSelfUpdate();
    }
}

Latest version

The script checks /latest for the latest tag (eg it would contain 1.0.1).

Download path to binary

The download path for a specific binary version is sourced from a JSON encoded values sourced from /versions (default). You can override that by using setVersionsPath.

{
    "1.0.0": "download/1.0.0/example-file",
    "1.0.1": "download/1.0.1/example-file"
}

By default, the versions file is tag/path. If the versions file contains more than the path, the default path source can be overridden to a specific key using setVersionsTagKey.

For example:

{
    "1.0.0": {"path": "download/1.0.0/example-file"},
    "1.0.1": {"path": "download/1.0.1/example-file"}
}
...
    public function handle()
    {
        ...
        $this->setVersionsTagKey('path');
        ...
    }
...

Hash comparing

The downloaded file is hash checked (SHA256). This hash string by default is found in the same path as the download file path (download/1.0.1/sha256).

You can change the default source by overriding the setHashSource method and returning a different constant.

If there is a top level json encoded file storing the hashes, set the source to CHECKSUM_TOP_LEVEL. Specify the file path by using setHashPath.

NOTE: This array is keyed to the download path discovered through the versions file. It must match to be able to retrieve the hash.

...
    public function handle()
    {
        ...
        $this->setHashSource(self::CHECKSUM_TOP_LEVEL);
        $this->setHashPath('checksums');
        ...
    }
...
{
    "download/1.0.0/example-file": "...",
    "download/1.0.1/example-file": "..."
}

If the hash is included in the versions file, set the source to CHECKSUM_VERSIONS. Specify the array key using setHashPath.

...
    public function handle()
    {
        ...
        $this->setHashSource(self::CHECKSUM_VERSIONS);
        $this->setHashPath('sha256');
        ...
    }
...
{
    "1.0.0": {"path": "download/1.0.0/example-file", "sha256": "..."},
    "1.0.1": {"path": "download/1.0.1/example-file", "sha256": "..."}
}

Build scripts

Looking for a build script to help create all the necessary files?

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

hnhdigital-os/laravel-console-self-update 适用场景与选型建议

hnhdigital-os/laravel-console-self-update 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 170 次下载、GitHub Stars 达 7, 最近一次更新时间为 2018 年 12 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 hnhdigital-os/laravel-console-self-update 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-29