phalcon / phalcon-devtools

Phalcon Developer Tools
https://docs.phalcon.io/latest/en/devtools
Other
1.33k stars 629 forks source link

[NFR] Custom commands feature #1518

Open BeMySlaveDarlin opened 2 years ago

BeMySlaveDarlin commented 2 years ago

Feature

Right now we have possibility to use custom scripts via \Phalcon\DevTools\Script::loadUserScripts(), but the way it done is outdated and legacy, requires usage of temp folder .phalcon

        if (!file_exists('.phalcon/project.ini')) {
            return;
        }

        $config = parse_ini_file('.phalcon/project.ini');

        if (!isset($config['scripts'])) {
            return;
        }

        foreach (explode(',', $config['scripts']) as $directory) {
            ...
        }

New point is to implement better and flexible behavior: for example config.php

return [
    'database' => [
        ...
    ],
    'application' => [
        ...
    ],
    'commands' => [
        'my-custom-command' => MyCustomCommand::class,
    ],
];

Where MyCustomCommand implements \Phalcon\DevTools\Commands\CommandsInterface And usage user@server:/var/www/app$ phalcon my-custom-command --custom-option=1

This will require first to finish #1455

Why we need it?

Nowadays all of popular frameworks have extendable cli tools, which allows to make CI/CD much cleaner and easier. It would be nice to have same scope in devtools