Task File

Disposable commands.

Mecha introduces task.php file functionality in the core version greater than 2.0.0, which is just an includable file that functions exactly the same as the index.php file, but is intended to be used once. This file will be stored along with the index.php file and may or may not exist depending on the requirements. All task.php files will be loaded automatically as the index.php file. But, the special thing about this file is that it is always equipped with a command to destroy itself when a condition has been met.

if (!is_dir($folder = LOT . DS . 'page')) {
    // Create folder if not exists
    mkdir($folder, 0777, true);
} else {
    // Self destruct
    unlink(__FILE__);
}

This file can be placed in any extensions, layout and even in the core folder.

.\
├── engine\
├── lot\
│   ├── cache\
│   ├── layout\
│   │   ├── …
│   │   ├── index.php
│   │   └── task.php ✔
│   ├── page\
│   └── x\
│       ├── …
│       └── art\
│           ├── index.php
│           └── task.php ✔
├── .htaccess
├── favicon.ico
├── index.php
├── state.php
├── task.php ✔
└── LICENSE

In the future, I may add a task.php file to the root directory in other versions to perform automatic repair tasks before this file will eventually destroy itself. So that I don’t need to provide a step-by-step guide to users about how to fix here and there after some errors occured during core update.

0 Comments

No comments yet.