PHPackages                             mahesh-kerai/update-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mahesh-kerai/update-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mahesh-kerai/update-generator
=============================

Laravel Update and New Installation ZIP Generator

v3.1.0(2mo ago)71.9k↑339.3%2MITPHPPHP &gt;=8.1

Since Aug 26Pushed 2mo agoCompare

[ Source](https://github.com/Maheshkerai/update-generator)[ Packagist](https://packagist.org/packages/mahesh-kerai/update-generator)[ RSS](/packages/mahesh-kerai-update-generator/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (7)Dependencies (10)Versions (8)Used By (0)

Update Generator
================

[](#update-generator)

[![Latest Stable Version](https://camo.githubusercontent.com/990b79a7f9718a6ceaecf06f24b7d8371ff7b1aeaa830892dd93ae4bab47b654/687474703a2f2f706f7365722e707567782e6f72672f6d61686573682d6b657261692f7570646174652d67656e657261746f722f76)](https://packagist.org/packages/mahesh-kerai/update-generator) [![Total Downloads](https://camo.githubusercontent.com/0f5daea51e57f4258af1272b4ddb59f8b697da9151f2ee61861b045cfc19a59b/687474703a2f2f706f7365722e707567782e6f72672f6d61686573682d6b657261692f7570646174652d67656e657261746f722f646f776e6c6f616473)](https://packagist.org/packages/mahesh-kerai/update-generator) [![License](https://camo.githubusercontent.com/826362400259a0eed32ecff3482ebd384bf3e8b9e7dcf833171883724e1cb600/687474703a2f2f706f7365722e707567782e6f72672f6d61686573682d6b657261692f7570646174652d67656e657261746f722f6c6963656e7365)](https://packagist.org/packages/mahesh-kerai/update-generator) [![PHP Version Require](https://camo.githubusercontent.com/36dc19b5b55567588ae9a3af3839eee103a38c8d7dcf01d301c1c8458258d5d6/687474703a2f2f706f7365722e707567782e6f72672f6d61686573682d6b657261692f7570646174652d67656e657261746f722f726571756972652f706870)](https://packagist.org/packages/mahesh-kerai/update-generator)

A robust Laravel package for generating update ZIP files and new installation packages based on Git repository changes.

Features
--------

[](#features)

- 🚀 **Git Integration**: Automatically detects files changed between specified dates or commit ranges
- 💻 **Modern Interactive CLI**: Stunning, boxed UI with radio-style selections for a premium developer experience
- 📦 **Multiple Package Types**: Generate update packages, new installation packages, or both
- 🛡️ **Security**: Safe Git command execution with proper validation
- 🔒 **Environment Sanitization**: Automatically sanitizes sensitive data in .env files for new installations
- 🧹 **Cache Management**: Automatic cache clearing before package generation
- 📝 **Logging**: Comprehensive logging for debugging and monitoring
- ⚙️ **Configurable**: Easy configuration for excluded paths and settings
- 🎯 **Type Safety**: Full PHP 8.1+ type safety with strict typing
- 📁 **Custom File Inclusion**: Explicitly include custom packages and essential files in updates
- 🗂️ **Smart Exclusions**: Wildcard patterns for excluding directory contents while preserving structure
- 🔄 **Commit-Based Support**: Generate updates based on specific Git SHAs (full/short)

Minimum Requirements
--------------------

[](#minimum-requirements)

RequirementVersionPHP8.1+Laravel9.x+Git2.0+Installation
------------

[](#installation)

### 1. Install the package

[](#1-install-the-package)

```
composer require mahesh-kerai/update-generator
```

System Requirements
-------------------

[](#system-requirements)

- **PHP**: 8.1 or higher
- **Laravel**: 9.0 or higher
- **PHP Extensions**:
    - `zip` extension (for creating ZIP archives)
    - `fileinfo` extension (for file type detection)
- **Operating Systems**: Windows, Linux, macOS (cross-platform compatible)

> **Note**: The package now uses PHP's built-in ZipArchive instead of external zip commands, making it fully compatible across all operating systems.

### 2. Publish configuration

[](#2-publish-configuration)

```
php artisan vendor:publish --tag=config
```

This creates the configuration file at `config/update-generator.php`

### 3. Configure excluded paths and additional files

[](#3-configure-excluded-paths-and-additional-files)

Edit `config/update-generator.php` to customize excluded paths and include additional files:

```
return [
    'exclude_update' => [
        'storage',
        'vendor',
        '.env',
        'node_modules',
        '.git',
        '.idea',
        'composer.lock',
        'package-lock.json',
        'yarn.lock',
        'public/storage',
        'public/uploads',
        'tests',
        'phpunit.xml',
        '.gitignore',
        '.env.example',
        'README.md',
        'CHANGELOG.md',
    ],

    /*
    |--------------------------------------------------------------------------
    | Additional files to include in update packages
    |--------------------------------------------------------------------------
    |
    | These files/folders will be explicitly included in update packages
    | even if they are in excluded paths (e.g., custom vendor packages)
    |
    */
    'add_update_file' => [
        'vendor/autoload.php',
        'vendor/mahesh-kerai',
        'vendor/composer',
    ],

    /*
    |--------------------------------------------------------------------------
    | Exclude paths for new installation packages
    |--------------------------------------------------------------------------
    |
    | These paths will be excluded when generating new installation packages
    | Note: .env file is included for fresh installations as it's required
    | Use wildcard patterns (*) to exclude contents while preserving directories
    |
    */
    'exclude_new' => [
        'storage/app/public',
        'storage/logs/*',           // Excludes log files, keeps directory
        'storage/framework/cache/data', // Excludes cache data, keeps directory
        'storage/framework/sessions/*', // Excludes session files, keeps directory
        'storage/framework/views/*',    // Excludes compiled views, keeps directory
        'storage/debugbar/*',           // Excludes debugbar files, keeps directory
        '.git',
        '.idea',
        'node_modules',
        'public/storage',
        'public/uploads',
        '.vscode',
        'storage/installed',
    ],

    'output_directory' => 'storage/app/update_files',
    'git_timeout' => 300,
    'enable_logging' => true,

    /*
    |--------------------------------------------------------------------------
    | Clear cache before generation
    |--------------------------------------------------------------------------
    |
    | Whether to clear all cache files before generating packages
    | This ensures no cached data is included in the packages
    |
    */
    'clear_cache_before_generation' => true,

    /*
    |--------------------------------------------------------------------------
    | Sanitize .env file
    |--------------------------------------------------------------------------
    |
    | Whether to sanitize the .env file by replacing sensitive values
    | with default values or null before generating packages
    |
    */
    'sanitize_env_file' => true,

    /*
    |--------------------------------------------------------------------------
    | .env file sanitization rules
    |--------------------------------------------------------------------------
    |
    | Define which environment variables should be sanitized and their
    | replacement values for new installation packages
    |
    */
    'env_sanitization_rules' => [
        'APP_KEY' => 'base64:your-app-key-here',
        'DB_PASSWORD' => '',
        'DB_USERNAME' => 'root',
        'DB_DATABASE' => 'laravel',
        'DB_HOST' => '127.0.0.1',
        'DB_PORT' => '3306',
        'MAIL_PASSWORD' => '',
        'MAIL_USERNAME' => '',
        'MAIL_HOST' => 'smtp.mailgun.org',
        'MAIL_PORT' => '587',
        'MAIL_ENCRYPTION' => 'tls',
        'MAIL_FROM_ADDRESS' => 'hello@example.com',
        'MAIL_FROM_NAME' => 'Laravel',
        'PUSHER_APP_KEY' => '',
        'PUSHER_APP_SECRET' => '',
        'PUSHER_APP_ID' => '',
        'PUSHER_APP_CLUSTER' => 'mt1',
        'MIX_PUSHER_APP_KEY' => '',
        'MIX_PUSHER_APP_CLUSTER' => 'mt1',
        'AWS_ACCESS_KEY_ID' => '',
        'AWS_SECRET_ACCESS_KEY' => '',
        'AWS_DEFAULT_REGION' => 'us-east-1',
        'AWS_BUCKET' => '',
        'REDIS_PASSWORD' => '',
        'REDIS_HOST' => '127.0.0.1',
        'REDIS_PORT' => '6379',
        'CACHE_DRIVER' => 'file',
        'SESSION_DRIVER' => 'file',
    ],
];
```

Usage
-----

[](#usage)

### Modern Interactive CLI Workflow (Recommended)

[](#modern-interactive-cli-workflow-recommended)

The easiest way to generate packages is to use the interactive wizard, which features a modern, boxed UI inspired by Laravel's official tools. Simply run the command without any arguments:

```
php artisan update:generate
```

The command will guide you through a structured, interactive process:

1. **Filtering Method**: Select between `Date Range` or `Commit Range` using arrow keys.
2. **Instructional Notes**: Contextual help will appear (e.g., format reminders).
3. **Conditional Inputs**:
    - **Date Range Mode**: Enter **Start Date** and **End Date** (`YYYY-MM-DD`).
    - **Commit Range Mode**: Enter **Starting Commit Reference** and **Ending Commit Reference** (Strictly SHAs only).
4. **Current Version**: Enter your system's current version (e.g., `1.0.0`).
5. **Update Version**: Enter the target update version (e.g., `1.1.0`).
6. **Type Selection**: Choose `both`, `update`, or `new` using the interactive radio-style selection.

Once all inputs are provided, a **Confirmation Summary** will be displayed inside a structured box for your final approval.

### Commit Range Mode Guidelines

[](#commit-range-mode-guidelines)

When using **Commit Range Mode**, please note the following:

Important

**Supported References:** Only **Full Git SHAs** and **Short Git SHAs** (e.g., `a1b2c3d`) are supported.

**Unsupported References:** You **cannot** use full commit messages as references. Ensure the starting commit precedes the ending commit in the repository's history.

### Inline Options (Backward Compatibility &amp; Automation)

[](#inline-options-backward-compatibility--automation)

For automated systems or advanced users, you can pass parameters directly. Providing these options will automatically bypass the interactive prompts:

**Date-Based Example:**

```
php artisan update:generate \
    --start_date=2025-01-01 \
    --end_date=2025-03-31 \
    --current_version=1.0.0 \
    --update_version=1.1.0 \
    --type=both
```

**Commit-Based Example:**

```
php artisan update:generate \
    --start_commit=a1b2c3d \
    --end_commit=e5f6g7h \
    --current_version=1.0.0 \
    --update_version=1.1.0 \
    --type=update
```

Input Parameters Explanation
----------------------------

[](#input-parameters-explanation)

ParameterFormat / OptionsDescription**Start Date**`YYYY-MM-DD`The beginning date to check Git history for modified or created files.**End Date**`YYYY-MM-DD`The ending date to check Git history.**Start Commit**Full/Short SHAThe starting commit SHA reference (Full or Short). *Commit messages not allowed.***End Commit**Full/Short SHAThe ending commit SHA reference. *Commit messages not allowed.***Current Version**e.g. `1.0.0`The current operational version of the project. Added to the generated `version_info.php`.**Update Version**e.g. `1.1.0`The target version after the update.**Type**`both`, `update`, `new`Defines the output. `update` extracts only changed files. `new` bundles the entire project.How It Works (Workflow)
-----------------------

[](#how-it-works-workflow)

1. **Git Diff Analysis**: If generating an update package, the system runs local Git commands to identify exactly which files were modified, created, or deleted between the provided **Date Range** or **Commit Range**.
2. **File Filtering**: Identified files are cross-referenced with your `exclude_update` and `add_update_file` configuration to ensure absolute correctness.
3. **Packaging Update Files**: All applicable files are replicated into a temporary environment and bundled into a `source_code.zip` archive.
4. **Packaging New Installation**: If requested, the system zips the entire project directory, cleanly bypassing paths marked in `exclude_new`. Furthermore, sensitive values inside `.env` are automatically sanitized.
5. **Versioning Details**: A `version_info.php` is generated containing the input versions to assist the end-user upgrade systems.

Requirements &amp; Prerequisites
--------------------------------

[](#requirements--prerequisites)

Before running the command, ensure your environment is fully prepared:

- **Git Context:** Must be run from within an initialized Git repository.
- **Project Setup:** Ensure `composer` dependencies are properly resolved and the application is structurally sound.
- **Correct File Permissions:** Write permissions are required at the `output_directory` path (default: `storage/app/update_files`).
- **Dependencies:** Standard PHP `zip` extension (ext-zip) is required for compression, and `git` CLI must be accessible in your system paths.
- **Valid Inputs:** Dates must stringently match the `YYYY-MM-DD` format.

Output Structure
----------------

[](#output-structure)

Depending on your selected **Type**, the following files and folders will be created inside the configured output directory (`storage/app/update_files` by default):

### Update Package

[](#update-package)

Generates only changed and new files:

```
Update 1.0.0-to-1.1.0.zip
├── source_code.zip (contains only changed project files)
└── version_info.php (version information)

```

### New Installation Package

[](#new-installation-package)

Generates a full installation bundle with sanitized credentials:

```
New_Installation_V1.1.0.zip
└── [all project files except excluded] (includes sanitized .env)

```

### Version Info File

[](#version-info-file)

```
