Skip to content

Laravel Auto Updater is a package that automates the update process for Laravel applications by dynamically fetching updates from GitHub, GitLab, Bitbucket, or custom endpoints.

License

Notifications You must be signed in to change notification settings

anisAronno/laravel-auto-updater

Repository files navigation

Laravel Auto Updater

A robust Laravel package facilitating automatic updates from GitHub, GitLab, Bitbucket, or custom repositories for your Laravel applications. Supports Laravel version 8 and above.

Table of Contents

Features

  • Multi-source support: Update from GitHub, GitLab, Bitbucket, or custom repositories
  • Simple configuration via environment variables and config file
  • Built-in commands for update checks and initiation
  • Exclusion of sensitive files/folders from updates
  • Comprehensive error handling and logging
  • Version tracking through composer.json
  • Global Blade component for easy integration
  • API endpoints for programmatic update management
  • Configurable middleware for API security

Installation

Install the package via Composer:

composer require anisaronno/laravel-auto-updater

Publish the configuration file:

php artisan vendor:publish --tag=auto-updater-config

This creates auto-updater.php in your config directory.

Optionally, publish assets and views:

php artisan vendor:publish --tag=auto-updater-assets
php artisan vendor:publish --tag=auto-updater-views

Configuration

Environment Variables

Add these to your .env file:

RELEASE_URL=https://github.com/anisAronno/laravel-starter
PURCHASE_KEY=your_optional_purchase_key
  • RELEASE_URL: Your repository's release URL
  • PURCHASE_KEY: (Optional) For authenticated APIs or private repos

Config File

The config/auto-updater.php file contains important settings:

  • Repository Configuration: The file uses RepositoryAdapterFactory to create an appropriate adapter based on your RELEASE_URL.
  • Excluded Items: Define files and folders to exclude from updates.
  • Middleware: Specify which middleware to apply to the auto-updater's API endpoints.

Excluding Items from Updates

Edit the exclude_items array in config/auto-updater.php:

"exclude_items" => [
    '.env',
    '.git',
    'storage',
    'node_modules',
    'vendor',
    // Add custom exclusions here
],

Set Middleware in the Config File

To configure the middleware, edit the middleware array in the config/auto-updater.php file:

"middleware" => ['web'],

By default, the middleware is set to web.

Application Version

Specify your app's version in composer.json:

{
    "version": "1.0.0"
}

After making configuration changes, refresh the config cache:

php artisan config:cache

Usage

Update Check Command

Check for available updates:

php artisan update:check

Update Initiate Command

Start the update process:

php artisan update:initiate

Scheduling Updates

Add to app/Console/Kernel.php (Laravel 10 and below):

protected function schedule(Schedule $schedule)
{
    $schedule->command('update:initiate')->daily();
}

For Laravel 11+, add to routes/console.php:

use Illuminate\Support\Facades\Schedule;

Schedule::command('update:initiate')->daily();

Modified Files Warning

The updater warns about modified project files, excluding .env and storage/.

Custom Update URL

For custom update sources, ensure your API returns:

{
  "version": "1.0.0",
  "download_url": "https://example.com/api/v1/release",
  "changelog": "Your changelog text"
}

API Endpoints

Access these endpoints for programmatic updates:

  • Check for updates: GET /api/auto-updater/check
  • Initiate update: POST /api/auto-updater/update

These endpoints are protected by the middleware specified in the config file.

Blade Component

Use the global component anywhere in your views:

<x-auto-updater />

Contribution Guidelines

We welcome contributions! Please see our Contribution Guide for details.

License

This package is open-source software licensed under the MIT License.

About

Laravel Auto Updater is a package that automates the update process for Laravel applications by dynamically fetching updates from GitHub, GitLab, Bitbucket, or custom endpoints.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published