cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[4.0.x] Rename Phalcon\Cli\Console

Open ekmst opened this issue 7 years ago • 24 comments

I propose to rename Phalcon\Cli\Console to Phalcon\Cli\Application. Similarly with Phalcon\Mvc\Application

ekmst avatar Dec 27 '18 15:12 ekmst

Well, it's still console (CLI) usage, not an application (web)? Depends how you look at it - IMO this is not necessity.

stamster avatar Dec 27 '18 16:12 stamster

I have no problem doing this, so long as the community decides whether it is best or not.

I will post this in discord to get feedback.

niden avatar Dec 27 '18 18:12 niden

In my opinion this creates unnecessary confusion. Just thinking from a developer efficiency standpoint, it'd be far to easy import the wrong class using your IDE. I can understand the viewpoint behind changing it but also, if it ain't broke...

npfedwards avatar Dec 27 '18 23:12 npfedwards

I like it separated in order to avoid confusion, in my case, I'm doing this from my bootstrap:

use Phalcon\Mvc\Application;
use Phalcon\Cli\Console;
...
$this->mode === 'console' ? Console::class : Application::class,

changing it would result extra noise as:

use Phalcon\Mvc\Application as MvcApplication;
use Phalcon\Cli\Application as CliApplication;
...
$this->mode === 'console' ? CliApplication::class : MvcApplication::class,

jturbide avatar Dec 28 '18 19:12 jturbide

I think that Mvc is already quite overused and I've changed it to Web in my framework. I plan to introduce a swoole async mode application for first class server-sent instead of overlaying it onto a "cli" setup. I dislike how much web first stuff there is in Phalcon and it shows that the cli stuff was added on mid-stride and then never refactored.

dschissler avatar Jan 02 '19 05:01 dschissler

@niden

I suggest the following options:

Phalcon\Mvc\Application to Phalcon\Application\Mvc, Phalcon\Mvc\Micro to Phalcon\Application\Micro, Phalcon\Cli\Console to Phalcon\Application\Cli or Phalcon\Application\Console.

And we take out the entry points to applications in a separate namespace.

ekmst avatar Jan 07 '19 16:01 ekmst

@ekmst +1

jturbide avatar Jan 07 '19 20:01 jturbide

Yeah I like it component based. Makes the most sense for organizing by feature. +1 @ekmst

virgofx avatar Jan 07 '19 22:01 virgofx

How about Phalcon\Application\Mvc becomes Phalcon\Application\Web? If its not in the Phalcon\Mvc namespace then it can be renamed.

So:

use Phalcon\Application\Cli;
use Phalcon\Application\Micro;
use Phalcon\Application\Web;

or

use Phalcon\Application\Cli as CliApp;
use Phalcon\Application\Micro as MicroApp;
use Phalcon\Application\Web as WebApp;

End the MVC madness in 2019.

dschissler avatar Jan 07 '19 22:01 dschissler

How about Phalcon\Application\Mvc becomes Phalcon\Application\Web? If its not in the Phalcon\Mvc namespace then it can be renamed.

So:

use Phalcon\Application\Cli;
use Phalcon\Application\Micro;
use Phalcon\Application\Web;

or

use Phalcon\Application\Cli as CliApp;
use Phalcon\Application\Micro as MicroApp;
use Phalcon\Application\Web as WebApp;

End the MVC madness in 2019.

I think Web is a general case. Since the framework itself implies the creation of web applications, it will be more appropriate to use the types of these applications as the name(mvc and micro).

And Cli is a special case.

ekmst avatar Jan 08 '19 12:01 ekmst

I think Web is a general case.

Ok maybe

Since the framework itself implies the creation of web applications

No

And Cli is a special case.

No

dschissler avatar Jan 08 '19 13:01 dschissler

@dschissler not all web app are using mvc, I think it's important to keep the pattern in order to differentiate different architectures

use Phalcon\Application\Cli;
use Phalcon\Application\Micro;
use Phalcon\Application\Mvc;
use Phalcon\Application\Hmvc;
use Phalcon\Application\Pac;
use Phalcon\Application\Mvvm;
use Phalcon\Application\Mvt;
...

jturbide avatar Jan 08 '19 13:01 jturbide

@dschissler not all web app are using mvc, I think it's important to keep the pattern in order to differentiate different architectures

use Phalcon\Application\Cli;
use Phalcon\Application\Micro;
use Phalcon\Application\Mvc;
use Phalcon\Application\Hmvc;
use Phalcon\Application\Pac;
use Phalcon\Application\Mvvm;
use Phalcon\Application\Mvt;
...

I agree

ekmst avatar Jan 08 '19 14:01 ekmst

Yep, +1 for Phalcon\Application\xyz as component but arch-specific stuff under required architecture namespace

so then it make sense to separate Web (pool by httpserver) and Cli (direct exec) ... but... also running from cli is possible with Swoole (like self-hosted app in NET for example),

use Phalcon\Application\Cli;
use Phalcon\Application\Web\Micro;
use Phalcon\Application\Web\Rest;
use Phalcon\Application\Web\Rest\Swoole;  // just an example
use Phalcon\Application\Web\Mvc;

ViltusVilks avatar Jan 08 '19 15:01 ViltusVilks

@ViltusVilks I agree in principle but it seems that the namespace is getting real deep.

I think that Swoole will be a thing with Phalcon at some point. I definitely plan to release a Swoole mode in my framework at some point. Right now I have a full cli with GNU style parsing and command help and a MVC. I guess that I was rebelling against "MVC" because there is too much shit in Phalcon\Mvc right now. The Phalcon\Application\xyz design feels best. Then move some other stuff like the other issue about the URL being moved out of Phalcon\Mvc as well. Then MVC might actually just have MVC stuff.

One thing that still bugs me though is that pretty much any type of Phalcon app is going to want models and most will want views (or at least simple views). So controllers are in there as well but that is specific to the MVC style application and is not relevant to others. Its a pretty small ideological issue though and I could live with it for perhaps until revisiting the issue in Phalcon 5.

dschissler avatar Jan 08 '19 17:01 dschissler

What about the following?

use Phalcon\Application\Type\Cli;
use Phalcon\Application\Type\Micro;
use Phalcon\Application\Type\Mvc;
use Phalcon\Application\Type\Hmvc;
use Phalcon\Application\Type\Pac;
use Phalcon\Application\Type\Mvvm;
use Phalcon\Application\Type\Mvt;

There is already Phalcon\Application\Exception. Additionally my Perch project has a lot of stuff in Perch\Application namespace because it is opinionated. For example there is an app config class which reads the root application.yml. I'd like to be able to use the same naming scheme as Phalcon. I think that claiming the entire Ph\App namespace could get us into trouble (it already does with the Exception, although I don't know if the application needs its own exception).

If you guys can get behind this in the next 1-2 days then I can make it happen (soon).

dschissler avatar Feb 17 '19 05:02 dschissler

@ViltusVilks I like your idea. I don't believe that we can use the root of Phalcon\Application namespace due to other stuff needing to go in there like Exception. So what about this, its basically the similar to using Type but separating by if its initiated from the cli or through a web server.

use Phalcon\Application\Cli\Console;
use Phalcon\Application\Cli\Pm;
use Phalcon\Application\Cli\Swoole;
use Phalcon\Application\Web\Micro;
use Phalcon\Application\Web\Mvc;

Guys we need to get moving on this since its unlikely to happen if we approaching a beta.

dschissler avatar Feb 24 '19 20:02 dschissler

I am still voting for my previous proposition without the cli/web context. I don't see any problem of sharing a namespace with other classes like Exception. In fact, I do this all the time in different other contexts.

Contradictory, within my application I currently use App\Cli\Console as well as App\Mvc\Application in order to match Phalcon's logic but in the end I wouldn't really mind altering that namespace for another explicit approach.

jturbide avatar Feb 27 '19 02:02 jturbide

I have four other files in my Perch\Application directory. It will be five with Exception.

[edit] I could bump them down I guess.

dschissler avatar Feb 27 '19 04:02 dschissler

Please vote in #13868 for the way to rename the application classes.

dschissler avatar Feb 28 '19 01:02 dschissler