承接 jalameta/jps-patcher 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jalameta/jps-patcher

最新稳定版本:v2.0.0

Composer 安装命令:

composer require jalameta/jps-patcher

包简介

Laravel patch scripts.

README 文档

README

A (migration like) patcher for a smoldering production update.

Total Downloads GitHub Workflow Status

Already tested on:

  • Laravel: 6.* | 7.* | 8.*
Background :

Our team has been made a stupid thing that affect database in our project. It was happens many times, and we are usually go tinkering or direct edit on a database to fix those problems. The problem is we need to record those change, so we made this package. Besides, we sometime need to doing bulk insert user for our application, so patch will be the best solution.

INSTALLATION

do either of this methods below.

  • via shell
composer require jalameta/jps-patcher
  • adding "jalameta/jps-patcher": "^2.0" to composer.json
{
  "require": {
    "jalameta/jps-patcher": "^2.0"
  }
}

POST INSTALLATION

this process is optional, you can skip it though.

  1. applying into your project.

    • Laravel >= 5.8

      • Automatically loaded :)
    • Laravel <= 5.8

      • Add the \Jalameta\Patcher\PatcherServiceProvider into providers array in config/app.php
  2. patches table creation.

     php artisan patcher:install

USAGE

CREATE NEW PATCH

for creating new patch you just need to run these following command

php artisan make:patch what_do_you_want_to_patch

wait, do you feels familiar huh?, we do too. The truth is, this package is extending laravel migration.

after run those command, you will see new file in patches folder. Those file will be like:

<?php

use Jalameta\Patcher\Patch;

class WhatDoYouWantToPatch extends Patch
{
    /**
     * Run patch script.
     *
     * @return void
     * @throws \Exception
     */
    public function patch()
    {
        // 
    }
}

Method patch on these file will be filled with your logic. in Jalameta\Patcher\Patch there is some useful properties that you can use for supporting your patch such as:

  1. $container: \Illuminate\Container\Container

  2. $command: \Illuminate\Console\Command

    we frequently used $command property to print process that we're doing. example:

    $this->command->warn('i patch something danger!');
    $this->command->confirm('do you wish to continue?');

    you can learn more about \Illuminate\Console\Command here.

  3. $logger: \Illuminate\Log\Logger

    $logger will store log in storage/logs/patches.log. if you want to change it, add this line below in your config/logging.php in channels section.

    [
        'channels' => [
            'patcher' => [
                 'driver' => 'patcher', // you can change me if you want
                 'path' => storage_path('logs/patches.log'), // change me
             ],
        ],
    ];

    you can learn more about \Illuminate\Log\Logger here

SHOW PATCH STATUS

php artisan patcher:status

Example:

my_project on  master [$!] via ⬢ v14.14.0 via 🐘 v7.4.11 on 🐳 v19.03.13 
➜ php artisan patcher:status
+------+---------------------------------------+-------+
| Ran? | Patch                                 | Batch |
+------+---------------------------------------+-------+
| Yes  | 2020_09_29_190531_fix_double_sections | 1     |
| Yes  | 2020_10_09_124616_add_attachment_beep | 1     |
+------+---------------------------------------+-------+

RUN A PATCH(ES)

php artisan patcher:run

Example:

my_project on  master [$!] via ⬢ v14.14.0 via 🐘 v7.4.11 on 🐳 v19.03.13 
➜ php artisan patcher:status
Patches table created successfully.
Patching: 2020_09_29_190531_fix_double_sections
Patched:  2020_09_29_190531_fix_double_sections (0.03 seconds)
Patching: 2020_10_09_124616_add_attachment_beep
Patched:  2020_10_09_124616_add_attachment_beep (0.06 seconds)

统计信息

  • 总下载量: 9.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-11