alphazframework / framework

Core files of AlphaZ Framework
https://alphazframework.github.io/
MIT License
16 stars 17 forks source link

console #325

Closed lablnet closed 2 years ago

lablnet commented 3 years ago

As i was thinking since the long time about new improved console so finally i try to find time and work on it.

Its new console, which support to register commands etc.. A simple hello world command may look like this

<?php

namespace App\Console\Commands;
use Zest\Console\Command;

class Hello extends Command
{
    protected $sign = "hello";
    protected $description = "Command to print hello message on screen";

    public function handle()
    {
        $this->write("<green>Hello World.</green>");
    }
}

In Zest Skeleton it should added to App/Config/Console.php

<?php

namespace Config;
use Zest\Console\Commands as InternalCommands;

class Commands extends InternalCommands {
    protected $commands = [
        ['hello',  \App\Console\Commands\Hello::class],
    ];
}

It also have few internals commands

Here is snapshot of list command rsz_screenshot_from_2020-11-28_18-24-34

@peter279k and @Maikuolan what do yo think about this approach?

The symfony console exists no matter, but i love to reinvent wheel, and the motive of Zest framework.

peter279k commented 3 years ago

Your works are very similar with Symfony/Components.

I don't think it's not very necessary to rebuild a console....Why don't you build a console on top of above component :)?

lablnet commented 3 years ago

Your works are very similar with Symfony/Components.

I don't think it's not very necessary to rebuild a console....Why don't you build a console on top of above component :)?

Because

The main purpose of Zest framework is to provide a very lightweight framework without any external dependencies except core and autoloader

Maikuolan commented 3 years ago

Seems like an interesting idea. Would be a nice addition to Zest, I think. :-)

I'm not super familiar with framework-based consoles though, TBH. Even Symfony's console, which seems to be reasonable popular AFAICT, isn't something I tend to ever use, except when necessary (e.g., when using a Symfony-based application which relies on their console).

peter279k commented 3 years ago

Just notice that the console about Laravel framework relies on the Symfony/Console.

My main suggestion is: We should consider using the lightweight PHP console to build the console Zest framework.

It should be easy to build and it can avoid "repeating yourself" :).

lablnet commented 3 years ago

My main suggestion is: We should consider using the lightweight PHP console to build the console Zest framework.

What do you mean by light weight php console

@peter279k

peter279k commented 3 years ago

You can find the console via the packagist.org site.

lablnet commented 3 years ago

You can find the console via the packagist.org site.

For now in this 'PR' I will continue a bit work the think about it. The proglen is that to include third party lib is violate term of Zest .

peter279k commented 3 years ago

You can find the console via the packagist.org site.

For now in this 'PR' I will continue a bit work the think about it. The proglen is that to include third party lib is violate term of Zest .

Agree. Go ahead with that.

lablnet commented 3 years ago

TODO

After that this PRwill ready to merge.