All Projects → travispessetto → script-updater-for-php

travispessetto / script-updater-for-php

Licence: MIT license
A MIT Licensed script updater for projects

Programming Languages

PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to script-updater-for-php

PATCH
The PATCH repository for issues tracking, wiki and shared material.
Stars: ✭ 34 (+41.67%)
Mutual labels:  updater, update
ProgramUpdater
PUF - Program Updater Framework. A library to easier the task of program updating
Stars: ✭ 14 (-41.67%)
Mutual labels:  updater, update
MacOS-All-In-One-Update-Script
Mac update shell script (Appstore, macOS, Homebrew and others)
Stars: ✭ 39 (+62.5%)
Mutual labels:  updater, update
Port-Able-Suite
🌐 Manager for portable applications
Stars: ✭ 35 (+45.83%)
Mutual labels:  updater, update
Appupdate
🚀 Android 版本更新 🚀 a library for android version update 🚀
Stars: ✭ 3,375 (+13962.5%)
Mutual labels:  updater, update
Update4j
Create your own auto-update framework
Stars: ✭ 497 (+1970.83%)
Mutual labels:  updater, update
vscode-updater
A simple script to automate downloading, installing and restarting Visual Studio Code.
Stars: ✭ 59 (+145.83%)
Mutual labels:  updater, update
iQuail
Easy to use cross-platform installer & updater for desktop applications
Stars: ✭ 20 (-16.67%)
Mutual labels:  updater, update
Appimageupdate
AppImageUpdate lets you update AppImages in a decentral way using information embedded in the AppImage itself.
Stars: ✭ 261 (+987.5%)
Mutual labels:  updater, update
Nupdate
A comfortable update solution for .NET-applications.
Stars: ✭ 394 (+1541.67%)
Mutual labels:  updater, update
Ember Cli Updater
ember-cli addon to help you update your ember-cli application or addon.
Stars: ✭ 32 (+33.33%)
Mutual labels:  updater, update
Electron Release Server
A fully featured, self-hosted release server for electron applications, compatible with auto-updater.
Stars: ✭ 1,600 (+6566.67%)
Mutual labels:  updater
Sparkler
A Rails webapp that gathers and displays system statistics from Sparkle app updater (macOS/app versions etc.)
Stars: ✭ 71 (+195.83%)
Mutual labels:  updater
Ucaresystem
An all-in-one, one click system maintenance application for Ubuntu/Debian operating systems and derivatives
Stars: ✭ 69 (+187.5%)
Mutual labels:  updater
Wine Origin Updater
Updater for Origin in Wine
Stars: ✭ 57 (+137.5%)
Mutual labels:  updater
Aerialcompanion
A companion app for the Aerial screen saver for macOS that takes care of install and auto-updates.
Stars: ✭ 144 (+500%)
Mutual labels:  updater
Update
Update is a new developer framework and CLI for automating updates of any kind in code projects. If you know how to use assemble, generate or verb, you'll know how to use update.
Stars: ✭ 106 (+341.67%)
Mutual labels:  updater
Proton Ge Custom Updater
Simple updater for custom Proton distributions
Stars: ✭ 57 (+137.5%)
Mutual labels:  updater
Ouroboros
Automatically update running docker containers with newest available image
Stars: ✭ 1,474 (+6041.67%)
Mutual labels:  updater
Apkupdater
APKUpdater is an open source tool that simplifies the process of finding updates for your installed apps.
Stars: ✭ 1,028 (+4183.33%)
Mutual labels:  updater

Español

Script Updater for PHP

Script Updater for PHP is an update script that can be used with any PHP project to update the files via a couple clicks. The script only requires that it can get at a update file that contains the current version as well as the local filesystem location and the remote location. So, potentially Amazon S3 could be used.

Did we mention that this update script can adapt to languages? All you need is the appropriate language files in js/langs and langs/php.

Screen Shots

Imgur

There is a new update

Imgur

The code is currently up to date

Imgur

The update has finished

Imgur

Prompt if you want to restore backup

Setup the Update Script

To use this update script you will need to define a YAML file that explains what to do for the update. This file must contain version and files. Under files there is two additional items, add and delete. The version must be a set of integers seperated by a period (.) the leftmost number is of greatest importance.

Both the add and delete items are sequences. With all items in the add sequence being a mapping with local and remote defined. local is where you want the downloaded file to go and remote is where to get it from the update server.

The script section defines two sections do and undo. The do section defines what will execute when all files have been added, updated, or deleted. Each script in the do section must define if it should be deleted after execution by setting delete to either true or false. See the example below if you are confused. In the undo section you have scripts that will need to be executed if someone chooses to revert to a backup. This section requires script, remote, and delete sections. These scripts will be added to the backup file and will be retrieved from remote. The delete section specifies if it will be deleted after the backup is restored.

If you want your users to be able to click a button when finished you can set finishUrl in the YAML file to a relative URL. When the button is clicked they will go to whatever this is set to. If this does not exist they will get a message that a finish button was not found.

Below is an example of a YAML update file:

version:    1.1.17
files:
        add:
            - {local: "foo/bar/writable/foobar.txt", remote: "files/foobar.txt"}
            - {local: "scripts/writefile.php", remote: "files/writefile.php.txt"}
        delete:
            - "foo/foo.txt"
scripts:
        do:
            - {script: "scripts/writefile.php", delete: true}
        undo:
            - {script: "scripts/deletefile.php", remote: "scripts/deletefile.php", delete: true}
finishUrl: "finished.html"

Setup the Updater

To set up the updater you must edit config.php. version_url is where you put the base url for your update files. version_file is the version file on the remote host with the information to update. update_folder is the folder on the local host that you want to serve as your base.

Changing the URL for Different Versions

If you would like to have each version have its own update script you can make sure you include the updaters config.php in the updates with the new location for that version.

Supported Languages

The following languages are supported:

Language Version
English All
Spanish All

If you would like a language here either contribute it and I will update this repository or request it and I will see if I can get someone to translate it into that language.

Plugins

Updater allows plugins to make your life a little bit easier. I mainly did this for tasks like authorization. To create a plugin simply put a php file in the plugins directory with a class named the same. See example.

<?php
    class Authorize
    {
        // Hooks go here
    }

Hooks

Constructor Hook

The contructor hook will execute when the controller constructor is called. Therefore, anything that should apply to all functions, such as authorization should be called there. This is done by adding the public function of ConstructorHook() to your plugin file. The constructor hooks really should either do nothing or return a header, such as forbidden if you do not want to continue.

<?php
    class Authorize
    {
        public function ContructorHook()
        {
            // Authorization logic use exit(); if you need to terminate.
        }
    }

An example of an Authorize plugin that would not authorize anyone is as follows:

class Authorize
{
    public function ConstructorHook()
    {
        // authorization logic here...call exit if not
        // authorized.
        header('HTTP/1.0 403 Forbidden');
        exit();
    }
}

Restoring Backups

When the user goes to the update screen it will check for the existance of backup-{version} files. If they exist then a prompt will ask if they would like to restore a backup or check for updates.

Current Failsafes

The following failsafes are in place:

Writability Check

All files are checked before downloading to make sure they are writable

File Backup

All files that are going to be added and currently exist or are going to be deleted are added to a backup file named backup-{version}.zip in the same folder as the updater script.

Note: No backup of any databases are taken at this time and probably will not happen anytime in the near future as I want this to be database agnostic. That said, it may take more work but you can use the first position in the script section to make a backup of the database.

The file backup will contain a YAML script name restore.yml that will provide instructions on how to recover the backup. It will simply contain two sections: delete and scripts. It will look similar to the following:

delete:
        - "scripts/foo.php"
        - "scripts/bar.php"
scripts:
        - {script: "scripts/rollbackmigration.php", delete: true}

Remote File Check

All remote files are checked to exist before they are installed.

Help Me Out

I would love people to fork this project and contribute. If not that I would be interested in who uses this product. See my website https://pessetto.com to find my email and shoot me a quick message if you use and like this product.

Tools

The following tools exist for testing purposes or to simply make your life easier when creating a update file. They can be found in the tools folder of this repository. Some may be accessed via a command line/terminal with PHP installed others will need to use a web browser.

Update Test

This script will generate two folders in the root of the repository, update-test and update-test-source. If you have a test webserver setup you can then test if the backup system works by visting update-test. This is good for testing updates and restoring for backups.

To run this script you will need to make sure the repository is somewhere the web browser can see it and then point the browser to the repsoitory's URL with appended with tools\update-test.php.

Notice of Spyc

In order to parse YAML we are using the Spyc library by Vladimir Andersen. This is licensed under the MIT License.

License

Copyright (c) 2020 Travis Pessetto

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].