承接 muyaedward/wbapp-updater 相关项目开发

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

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

muyaedward/wbapp-updater

Composer 安装命令:

composer require muyaedward/wbapp-updater

包简介

Providing an auto-updating functionality for your self-hosted Laravel application.

README 文档

README

Latest Stable Version Total Downloads Build Status StyleCI codecov

This package provides some basic methods to implement a self updating functionality for your Laravel 5 application. Already bundled are some methods to provide a self-update mechanism via Github.

Usually you need this when distributing a self-hosted Laravel application that needs some updating mechanism, as you do not want to bother your lovely users with Git and/or Composer commands ;-)

Install with Composer

There are currently two branches:

  • master: Compatible with PHP 7.x
  • 5.x: Compatible with PHP 5.5 + 5.6

Please select the right branch for your PHP version accordingly.

To install the latest version from the master using Composer:

$ composer require codedge/laravel-selfupdater

This adds the codedge/laravel-selfupdater package to your composer.json and downloads the project.

You need to include the service provider in your config/app.php [1] and optionally the facade [2]:

// config/app.php

return [

    //...
    
    'providers' => [
        // ...
        
        Codedge\Updater\UpdaterServiceProvider::class, // [1]
    ],
    
    // ...
    
    'aliases' => [
        // ...
        
        'Updater' => Codedge\Updater\UpdaterManager::class, // [2]

]

Additionally add the listener to your app/Providers/EventServiceProvider.php:

// app/Providers/EventServiceProvider.php

/**
 * The event handler mappings for the application.
 *
 * @var array
 */
protected $listen = [
    // ...
    
    \Codedge\Updater\Events\UpdateAvailable::class => [
        \Codedge\Updater\Listeners\SendUpdateAvailableNotification::class
    ],
    \Codedge\Updater\Events\UpdateSucceeded::class => [
        \Codedge\Updater\Listeners\SendUpdateSucceededNotification::class
    ],

];

Configuration

After installing the package you need to publish the configuration file via

$ php artisan vendor:publish --provider="Codedge\Updater\UpdaterServiceProvider"

Note: Please enter correct value for vendor and repository name in your config/self-updater.php if you want to use Github as source for your updates.

Running artisan commands

Artisan commands can be run before or after the update process and can be configured in config/self-updater.php:

Example:

'artisan_commands' => [
    'pre_update' => [
        'updater:prepare' => [
            'class' => \App\Console\Commands\PreUpdateTasks::class,
            'params' => []
        ],
    ],
    'post_update' => [
        'postupdate:cleanup' => [
            'class' => \App\Console\Commands\PostUpdateCleanup::class,
            'params' => [
                'log' => 1,
                'reset' => false,
                // etc.
            ]
        ]
    ]
]

Notifications via email

You need to specify a recipient email address and a recipient name to receive update available notifications. You can specify these values by adding SELF_UPDATER_MAILTO_NAME and SELF_UPDATER_MAILTO_ADDRESS to your .env file.

Config name Description
SELF_UPDATER_MAILTO_NAME Name of email recipient
SELF_UPDATER_MAILTO_ADDRESS Address of email recipient
SELF_UPDATER_MAILTO_UPDATE_AVAILABLE_SUBJECT Subject of update available email
SELF_UPDATER_MAILTO_UPDATE_SUCCEEDED_SUBJECT Subject of update succeeded email

Usage

To start an update process, i. e. in a controller, just use:

public function update()
{
    // This downloads and install the latest version of your repo
    Updater::update();
    
    // Just download the source and do the actual update elsewhere
    Updater::fetch();
    
    // Check if a new version is available and pass current version
    Updater::isNewVersionAvailable('1.2');
}

Of course you can inject the updater via method injection:

public function update(UpdaterManager $updater)
{

    $updater->update(); // Same as above
    
    // .. and shorthand for this:
    $updater->source()->update;
    
    $updater->fetch() // Same as above...
}

Note: Currently the fetching of the source is a synchronous process. It is not run in background.

Using Github

The package comes with a Github source repository type to fetch releases from Github - basically use Github to pull the latest version of your software.

Just make sure you set the proper repository in your config/self-updater.php file.

Extending and adding new source repository types

You want to pull your new versions from elsewhere? Feel free to create your own source repository type somewhere but keep in mind for the new source repository type:

  • It needs to extend AbstractRepositoryType
  • It needs to implement SourceRepositoryTypeContract

So the perfect class head looks like

class BitbucketRepositoryType extends AbstractRepositoryType implements SourceRepositoryTypeContract

Afterwards you may create your own service provider, i. e. BitbucketUpdaterServiceProvider, with your boot method like so:

public function boot()
{
    Updater::extend('bitbucket', function($app) {
        return Updater::sourceRepository(new BitbucketRepositoryType);
    });
}

Now you call your own update source with:

public function update(UpdaterManager $updater)
{
    $updater->source('bitbucket')->update();
}

Contributing

Please see the contributing guide.

Roadmap

Just a quickly sketched roadmap what still needs to be implemented.

Licence

The MIT License (MIT). Please see Licencse file for more information.

muyaedward/wbapp-updater 适用场景与选型建议

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

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

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

围绕 muyaedward/wbapp-updater 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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