osenco/updater
Composer 安装命令:
composer require osenco/updater
包简介
Providing an auto-updating functionality for your self-hosted Laravel application.
关键字:
README 文档
README
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 updater mechanism via Github.
Usually you need this when distributing a self-hosted Laravel application that needs some updating mechanism without Composer.
Compatibility
- PHP: 7.3 & 7.4
- Laravel: 6.x & 7.x
Install
To install the latest version from the master using Composer:
$ composer require osenco/updater
Configuration
After installing the package you need to publish the configuration file via
$ php artisan vendor:publish --provider="Osen\Updater\UpdaterServiceProvider"
Note: Please enter correct value for vendor and repository name in your config/updater.php if you want to use Github as source for your updates.
ℹ️ Setting the currently installed version
Before starting an update, make sure to set the version installed correctly.
You're responsible to set the current version installed, either in the config file or better via the env variable UPDATER_VERSION_INSTALLED.
tag-based updates
Set the installed version to one of the tags set for a release.
branch-based updates
Set the installed version to to a datetime of one of the latest commits.
A valid version would be: 2020-04-19T22:35:48Z
Running artisan commands
Artisan commands can be run before or after the update process and can be configured in config/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 UPDATER_MAILTO_NAME and
UPDATER_MAILTO_ADDRESS to your .env file.
| Config name | Description |
|---|---|
| UPDATER_MAILTO_NAME | Name of email recipient |
| UPDATER_MAILTO_ADDRESS | Address of email recipient |
| UPDATER_MAILTO_UPDATE_AVAILABLE_SUBJECT | Subject of update available email |
| UPDATER_MAILTO_UPDATE_SUCCEEDED_SUBJECT | Subject of update succeeded email |
Private repositories
Private repositories can be accessed via (Bearer) tokens. Each repository inside the config file should have
a private_access_token field, where you can set the token.
Note: Do not prefix the token with Bearer. This is done automatically.
Usage
To start an update process, i. e. in a controller, just use:
Route::get('/', function (\Osen\Updater\UpdaterManager $updater) { // Check if new version is available if($updater->source()->isNewVersionAvailable()) { // Get the current installed version echo $updater->source()->getVersionInstalled(); // Get the new version available $versionAvailable = $updater->source()->getVersionAvailable(); // Create a release $release = $updater->source()->fetch($versionAvailable); // Run the update process $updater->source()->update($release); } else { echo "No new version available."; } });
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/updater.php
file.
Tag-based updates
This is the default. Updates will be fetched by using a tagged commit, aka release.
Branch-based updates
Select the branch that should be used via the use_branch setting inside the configuration.
// ... 'repository_types' => [ 'github' => [ 'type' => 'github', 'repository_vendor' => env('UPDATER_REPO_VENDOR', ''), 'repository_name' => env('UPDATER_REPO_NAME', ''), // ... 'use_branch' => 'v2', ], // ... ];
Using Http archives
The package comes with an Http source repository type to fetch releases from an HTTP directory listing containing zip archives.
To run with HTTP archives, use following settings in your .env file:
| Config name | Value / Description |
|---|---|
| UPDATER_SOURCE | http |
| UPDATER_REPO_URL | Archive URL, e.g. http://archive.webapp/ |
| UPDATER_PKG_FILENAME_FORMAT | Zip package filename format |
| UPDATER_DOWNLOAD_PATH | Download path on the webapp host server |
The archive URL should contain nothing more than a simple directory listing with corresponding zip-Archives.
UPDATER_PKG_FILENAME_FORMAT contains the filename format for all webapp update packages. I.e. when the update packages listed on the archive URL contain names like webapp-v1.2.0.zip, webapp-v1.3.5.zip, ... then the format should be webapp-v_VERSION_. The _VERSION_ part is used as semantic versionioning variable for MAJOR.MINOR.PATCH versioning. The zip-extension is automatically added.
The target archive files must be zip archives and should contain all files on root level, not within an additional folder named like the archive itself.
Contributing
Please see the contributing guide.
Licence
The MIT License (MIT). Please see Licence file for more information.
osenco/updater 适用场景与选型建议
osenco/updater 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 05 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「update」 「laravel」 「updater」 「auto-update」 「auto update」 「self update」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 osenco/updater 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 osenco/updater 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 osenco/updater 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Checks if any composer packages needs to be updated.
Migration generator for Yii 2.
A simple class to integrate with Git Updater for standalone plugin/theme updates.
Composer plugin for running post-install/post-update scripts of your project's dependencies
A module to backup and update SimpleSAMLphp installations
Update Elasticsearch data or clear cache when the model or any related model is updated, created or deleted.
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-19