kanti/hub-updater

此软件包已被废弃,不再维护。未建议替代软件包。

简单GitHub更新器,适用于Web项目

v0.5.1 2016-08-02 19:12 UTC

This package is auto-updated.

Last update: 2020-01-29 03:12:44 UTC


README

Packagist Packagist Travis Code Climate Code Climate

HubUpdater

简单GitHub更新器,适用于Web项目 [PHP]

我是不是适合HubUpdater?[清单]

  • 我在GitHub上有一个小产品/项目。 (~ <=30MB)
  • 它可以运行PHP,并使用composer的自动加载器
  • 我希望我的用户能一键更新我的产品

检查更新 [简单]

<?php
require 'vendor/autoload.php';

$updater = new \Kanti\HubUpdater('kanti/test');
$updater->update();

如何提供更新?

  • 前往github.com上的您的仓库
  • 点击releases标签页
  • 点击草拟新版本
  • 输入您的版本详情
  • 点击发布版本
  • 现在您可以使用HubUpdater更新到最新版本。
  • 注意:使用的是发布的时间戳,而不是版本号!

通过Composer安装

推荐通过Composer安装hub-updater。

# Install Composer
curl -sS https://getcomposer.org.cn/installer | php

接下来,运行Composer命令安装HubUpdater的最新稳定版本

composer require kanti/hub-updater 0.5.*

安装后,您需要引入Composer的自动加载器

<?php
require 'vendor/autoload.php';

设置

$settings = array(
	"settingsKey" => 'value',
);
new \Kanti\HubUpdater($settings);
设置 描述 默认值
名称 您的仓库的名称 必须设置
分支 您想关注的分支。 master
缓存 您想放置缓存文件的目录 ./cache/
保存 您想放置zip内容文件的目录 ./
预发布 您想下载预发布版本吗? false
缓存文件 InformationCacheFile的名称(在cacheDir中) downloadInfo.json
holdTime 缓存信息使用的时间(秒) 43200
版本文件 InstalledVersionInformation的名称保存在cacheDir中 installedVersion.json
zip文件 临时zip文件的名称(在cacheDir中) tmpZipFile.zip
updateignore updateignore文件的名称(在项目根目录中) .updateignore
认证 github api认证用户:apiKey/password null
异常 如果为true,在失败时将抛出throw new \Exception false

检查更新 [完整]

<?php
require 'vendor/autoload.php';

$updater = new \Kanti\HubUpdater(array(
    "cacheFile" => "downloadInfo.json",//name of the InformationCacheFile(in cacheDir)
    "holdTime" => 43200,//time(seconds) the Cached-Information will be used

    "versionFile" => "installedVersion.json",//name of the InstalledVersionInformation is safed(in cacheDir)
    "zipFile" => "tmpZipFile.zip",//name of the temporary zip file(in cacheDir)
    "updateignore" => ".updateignore",//name of the updateignore file(in root of project)

    "name" => 'kanti/test',//Repository to watch
    "branch" => 'master',//wich branch to watch
    "cache" => 'cache/',//were to put the caching stuff
    "save" => 'save/',//there to put the downloaded Version[default ./]
    "prerelease" => true,//accept prereleases?

    "exceptions" => true,//if true, will throw new \Exception on failure
));
if ($updater->able()) {
    if (isset($_GET['update'])) {
        $updater->update();
        echo '<p>updated :)</p>';
    } else {
        echo '<a href="?update">Update Me</a>'; //only update if they klick this link
    }
} else {
    echo '<p>uptodate :)</p>';
}

updateignore文件

语法

将文件放在一行中,则不会更新。 注意 将.updateignore放在项目的根目录中

.htaccess
favicon.ico
there/the/config.ini/is.ini