{"id":19973815,"url":"https://github.com/chez14/f3-ilgar","last_synced_at":"2025-05-04T02:32:19.324Z","repository":{"id":46198399,"uuid":"141909435","full_name":"chez14/f3-ilgar","owner":"chez14","description":"A simple migration tool for Fat-Free Framework","archived":false,"fork":false,"pushed_at":"2024-06-17T17:10:57.000Z","size":273,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-14T11:28:33.109Z","etag":null,"topics":["database","fat-free-framework","migration","migration-tool","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chez14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-22T15:52:50.000Z","updated_at":"2021-04-09T09:04:07.000Z","dependencies_parsed_at":"2022-09-23T05:51:25.416Z","dependency_job_id":null,"html_url":"https://github.com/chez14/f3-ilgar","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chez14%2Ff3-ilgar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chez14%2Ff3-ilgar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chez14%2Ff3-ilgar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chez14%2Ff3-ilgar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chez14","download_url":"https://codeload.github.com/chez14/f3-ilgar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224379908,"owners_count":17301525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","fat-free-framework","migration","migration-tool","php"],"created_at":"2024-11-13T03:13:00.850Z","updated_at":"2024-11-13T03:13:01.355Z","avatar_url":"https://github.com/chez14.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ilgar \n[![PHP from Packagist](https://img.shields.io/packagist/php-v/chez14/f3-ilgar.svg?style=flat-square)](https://github.com/chez14/f3-ilgar)\n [![Travis (.org)](https://img.shields.io/travis/chez14/f3-ilgar.svg?style=flat-square)](https://github.com/chez14/f3-ilgar) [![Packagist](https://img.shields.io/packagist/v/chez14/f3-ilgar.svg?style=flat-square)](https://packagist.org/packages/chez14/f3-ilgar) [![GitHub release](https://img.shields.io/github/release/chez14/f3-ilgar.svg?style=flat-square)](https://github.com/chez14/f3-ilgar)\n\nQuick and simple migration tool for Fat-Free Framework.\n\n\n## Getting Started\n1. Install via Composer\n    ```bash\n    composer require chez14/f3-ilgar\n    ```\n\n2. Decide your bombarding option\n         \n    - **Do it with default configuration?**\n        Default settings:\n\n        - Call `/ilgar/migrate` to do migration\n\n        - Use `Migration` as your migration class namespace prefix\n\n        - Migration packets placed in a `Migration` or `migration` folder in your project root folder.\n\n        Then, just add this to your `index.php` file:\n        ```php\n        \\Chez14\\Ilgar\\Boot::now();\n        ```\n\n    - **Do it with your own style and custom security?**\n\n        Just invoke `\\Chez14\\Ilgar\\Boot::trigger_on();` Anywhere at your controller. This will trigger migration process and returns [quick stats](#quick-stats).\n\n3. Create your first ever migration packet\n\n4. Deploy migration by accessing `/ilgar/migrate`\n    ```bash\n    curl http://localhost:8087/ilgar/migrate\n    ```\n\n    or\n\n    ```bash\n    php index.php /ilgar/migrate\n    ```\n\n## `MigrationPacket` Class Example\n\nThis file is available on your `migration` folder, located on your project root folder. Alternatively you can set the folder by setting `ILGAR.path`.\n\n```php\n$this-\u003ef3-\u003eset('ILGAR.path', \"new-folder/\");\n```\n\n\u003chr\u003e\n\n**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.\n\n**IMPORTANT!** You need to **extends** `\\Chez14\\Ilgar\\MigrationPacket` class. This will ensure required methods is always available and dependable.\n\n\u003chr\u003e\n\nHere's your file: `1-test01.php`.\n\n```php\nnamespace Migration;\n\nclass Test01 extends \\Chez14\\Ilgar\\MigrationPacket {\n    public function on_migrate(){\n        // Do your things here!\n        // All the F3 object were loaded, F3 routines executed,\n        // this will just like you doing things in your controller file.\n        \n        $f3 = \\F3::instance(); //get the $f3 from here.\n        \n        echo \"Hello from Test01 Migration package\";\n    }\n\n    public function on_failed(\\Exception $e) {\n\n    }\n}\n```\n\n\n\n## `MigrationPacket` abstract class\nIt's just a normal class. With something that you need to implement:\n - `on_migrate()`\n - `on_failed(\\Exception $e)`\n\nIlgar 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`).\n\nMore convenient event-based functions (all of this is optional):\n - `pre_migrate()`\n\n    Before the migration event. This might be useful if you want to prepare something first.\n\n    Please check `is_migratable` if you want to wanted to do checks.\n\n - `post_migrate()`\n   \n    After migration event. This will be executed when the packet were successfully executed.\n\n - `is_migratable()` \n\n    Validates current packet if it is applicable. This must return true in order to make this packet executed.\n\n## Quick Api for Ilgar\nIlgar'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:\n\n### get_current_version()\nreturns an `int`.\n\nThis integer represent current migration version point, declared by the filename.\n\nWill load the version from `migration.json`.\n\n### reset_version()\nreturns void.\n\nWill forcefully delete `migration.json` at designated path.\n\n### get_stats()\n\nreturns [quick stats](#quick-stats).\n\nThis will return current statistics with the migrations.\n\n## Quick Stats\n\nQuick stats is a array, consisting:\n\n```php\n$stats = [\n    \"success\" =\u003e $counter, // how many migration executed\n    \"last_exception\" =\u003e $failed, // last exception occured, this is an Exception object.\n    \"version\" =\u003e $current // current version applied\n];\n```\n\n\n\n## License\nYes, [GPLv3](LICENSE).\n\n## FAQ and RAQ (Rarely Asked Question)\n\n### Why naming it \"Ilgar\"?\n[Ilgar](http://worldtrigger.wikia.com/wiki/Ilgar) is a bombarding-type Trion Warrior. It's used by [Aftocrator](http://worldtrigger.wikia.com/wiki/Aftokrator) and [Chion](http://worldtrigger.wikia.com/wiki/Chion) for invasion.\nYes, it's meant to bombarding the database with migration packets.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchez14%2Ff3-ilgar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchez14%2Ff3-ilgar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchez14%2Ff3-ilgar/lists"}