在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):codedge/laravel-selfupdater开源软件地址(OpenSource Url):https://github.com/codedge/laravel-selfupdater开源编程语言(OpenSource Language):PHP 99.9%开源软件介绍(OpenSource Introduction):Laravel Application Self-UpdaterThis package provides some basic methods to implement a self updating functionality for your Laravel application. Supported update provider:
Usually you need this when distributing a self-hosted Laravel application that needs some updating mechanism without Composer. InstallTo install the latest version from the master using Composer: $ composer require codedge/laravel-selfupdater ConfigurationAfter 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 Setting the currently installed versionBefore 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
|
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 |
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.
Bearer
. This is done automatically.
To start an update process, i. e. in a controller, just use:
Route::get('/', function (\Codedge\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.
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.
This is the default. Updates will be fetched by using a tagged commit, aka release.
Select the branch that should be used via the use_branch
setting inside the configuration.
// ...
'repository_types' => [
'github' => [
'type' => 'github',
'repository_vendor' => env('SELF_UPDATER_REPO_VENDOR', ''),
'repository_name' => env('SELF_UPDATER_REPO_NAME', ''),
// ...
'use_branch' => 'v2',
],
// ...
];
Configure Gitlab either via the config/self-updater.php
or use the appropriate environment variables.
// ...
'repository_types' => [
'gitlab' => [
'type' => 'gitlab',
'repository_id' => env('SELF_UPDATER_REPO_URL', ''),
'download_path' => env('SELF_UPDATER_DOWNLOAD_PATH', '/tmp'),
'private_access_token' => env('SELF_UPDATER_GITLAB_PRIVATE_ACCESS_TOKEN', ''),
],
// ...
];
SELF_UPDATER_REPO_URL
, only specify your repository id.
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 |
---|---|
SELF_UPDATER_SOURCE | http |
SELF_UPDATER_REPO_URL | Archive URL, e.g. http://archive.webapp/ |
SELF_UPDATER_PKG_FILENAME_FORMAT | Zip package filename format |
SELF_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.
SELF_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.
Please see the contributing guide.
The MIT License (MIT). Please see Licence file for more information.
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论