PHP code example of jeffersongoncalves / laravel-zero-self-update
1. Go to this page and download the library: Download jeffersongoncalves/laravel-zero-self-update library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jeffersongoncalves / laravel-zero-self-update example snippets
namespace App\Commands;
use JeffersonGoncalves\LaravelZero\SelfUpdate\SelfUpdateCommand as BaseSelfUpdateCommand;
class SelfUpdateCommand extends BaseSelfUpdateCommand
{
protected function githubRepo(): string
{
return 'jeffersongoncalves/git-worktree-cli';
}
protected function assetName(): string
{
return 'git-worktree.phar';
}
protected function tempPrefix(): string
{
return 'git_worktree_';
}
protected function currentVersion(): string
{
return config('app.version', 'unreleased');
}
}
use JeffersonGoncalves\LaravelZero\SelfUpdate\PharUpdater;
$updater = new PharUpdater(
githubRepo: 'jeffersongoncalves/git-worktree-cli',
assetName: 'git-worktree.phar',
tempPrefix: 'git_worktree_',
currentVersion: config('app.version', 'unreleased'),
);
$release = $updater->getLatestRelease(); // ['tag' => 'v1.2.0', 'url' => '...']
if ($updater->isUpdateAvailable($updater->getCurrentVersion(), $release['tag'])) {
$tempFile = $updater->download($release['url']);
$updater->replacePhar($tempFile);
}