Simple Github Updater for Web Projects [PHP]
- I have a little product/projekt on github. (~ <=30MB)
- it can run PHP and uses composers autoloader
- I want my users to update my Product with one click
<?php
require 'vendor/autoload.php';
$updater = new \Kanti\HubUpdater('kanti/test');
$updater->update();
- Go to your Repository on github.com ‣‣
- click on the
releases
tab ‣‣ - click on
Draft a new release
‣‣ - Enter your release details ‣‣
- click on
Publish release
‣‣ - now you can use HubUpdater to update to the newest version.
- note: The timestamp of the release is used. NOT the version number!!
The recommended way to install hub-updater is through Composer.
# Install Composer
curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of HubUpdater:
composer require kanti/hub-updater 0.5.*
After installing, you need to require Composer's autoloader:
<?php
require 'vendor/autoload.php';
$settings = array(
"settingsKey" => 'value',
);
new \Kanti\HubUpdater($settings);
setting | description | default |
---|---|---|
name | the name your Repository has | must be set |
branch | the branch you like to watch. | master |
cache | the directory you like to put the cache stuff | ./cache/ |
save | the directory you like to put the content of the zip | ./ |
prerelease | would you like to download the prereleases? | false |
cacheFile | name of the InformationCacheFile(in cacheDir) | downloadInfo.json |
holdTime | time(seconds) the Cached-Information will be used | 43200 |
versionFile | name of the InstalledVersionInformation is safed(in cacheDir) | installedVersion.json |
zipFile | name of the temporary zip file(in cacheDir) | tmpZipFile.zip |
updateignore | name of the updateignore file(in root of project) | .updateignore |
auth | github api auth user:apiKey/password | null |
exceptions | if true, will throw new \Exception on failure |
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>';
}
put a file in one line and it will not be updated. note put the .updateignore in your projects root directory
.htaccess
favicon.ico
there/the/config.ini/is.ini