定制 chez14/f3-ilgar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

chez14/f3-ilgar

Composer 安装命令:

composer require chez14/f3-ilgar

包简介

A simple migration tool for Fat-Free Framework

README 文档

README

PHP from Packagist Travis (.org) Packagist GitHub release

Quick and simple migration tool for Fat-Free Framework.

Getting Started

  1. Install via Composer

    composer require chez14/f3-ilgar
  2. Decide your bombarding option

    • Do it with default configuration? Default settings:

      • Call /ilgar/migrate to do migration

      • Use Migration as your migration class namespace prefix

      • Migration packets placed in a Migration or migration folder in your project root folder.

      Then, just add this to your index.php file:

      \Chez14\Ilgar\Boot::now();
    • Do it with your own style and custom security?

      Just invoke \Chez14\Ilgar\Boot::trigger_on(); Anywhere at your controller. This will trigger migration process and returns quick stats.

  3. Create your first ever migration packet

  4. Deploy migration by accessing /ilgar/migrate

    curl http://localhost:8087/ilgar/migrate

    or

    php index.php /ilgar/migrate

MigrationPacket Class Example

This file is available on your migration folder, located on your project root folder. Alternatively you can set the folder by setting ILGAR.path.

$this->f3->set('ILGAR.path', "new-folder/");

IMPORTANT! The file name should be formatted as "0-classname.php", where the 0 is any number (you can use just normal number 1-ClassName.php, or CI-style timestamp 180901012400-ClassName.php), seperated with single dash, and followed with your class name, either in lowercase, SnakeCase, or camelCase.

IMPORTANT! You need to extends \Chez14\Ilgar\MigrationPacket class. This will ensure required methods is always available and dependable.

Here's your file: 1-test01.php.

namespace Migration;

class Test01 extends \Chez14\Ilgar\MigrationPacket {
    public function on_migrate(){
        // Do your things here!
        // All the F3 object were loaded, F3 routines executed,
        // this will just like you doing things in your controller file.
        
        $f3 = \F3::instance(); //get the $f3 from here.
        
        echo "Hello from Test01 Migration package";
    }

    public function on_failed(\Exception $e) {

    }
}

MigrationPacket abstract class

It's just a normal class. With something that you need to implement:

  • on_migrate()
  • on_failed(\Exception $e)

Ilgar has 2 ability, bomb and self-destruct. Bomb means do the migration mission (on_migrate), self-destruct means when it failed do the mission it will use their remaining power to do suicide bombing, in this matter, it means rollback the migration mission (on_failed).

More convenient event-based functions (all of this is optional):

  • pre_migrate()

    Before the migration event. This might be useful if you want to prepare something first.

    Please check is_migratable if you want to wanted to do checks.

  • post_migrate()

    After migration event. This will be executed when the packet were successfully executed.

  • is_migratable()

    Validates current packet if it is applicable. This must return true in order to make this packet executed.

Quick Api for Ilgar

Ilgar's API is available on Chez14\Ilgar\Internal class. It's a \Prefab child class, do if you wanted to get it's instance, you can obtain the instance by calling Chez14\Ilgar\Internal::instance(). Aaanyway, here's the API list:

get_current_version()

returns an int.

This integer represent current migration version point, declared by the filename.

Will load the version from migration.json.

reset_version()

returns void.

Will forcefully delete migration.json at designated path.

get_stats()

returns quick stats.

This will return current statistics with the migrations.

Quick Stats

Quick stats is a array, consisting:

$stats = [
    "success" => $counter, // how many migration executed
    "last_exception" => $failed, // last exception occured, this is an Exception object.
    "version" => $current // current version applied
];

License

Yes, GPLv3.

FAQ and RAQ (Rarely Asked Question)

Why naming it "Ilgar"?

Ilgar is a bombarding-type Trion Warrior. It's used by Aftocrator and Chion for invasion. Yes, it's meant to bombarding the database with migration packets.

chez14/f3-ilgar 适用场景与选型建议

chez14/f3-ilgar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 650 次下载、GitHub Stars 达 5, 最近一次更新时间为 2018 年 09 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「migration」 「migrate」 「fat-free framework」 「F3」 「ilgar」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 chez14/f3-ilgar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 chez14/f3-ilgar 我们能提供哪些服务?
定制开发 / 二次开发

基于 chez14/f3-ilgar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 650
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 18
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2018-09-03