Welcome Guest, Not a member yet? Register   Sign In

tl;dr; 4.2 RouteCollection::cli() - depracated; 5.0 RouteCollection::cli() - removed

In versions of CodeIgniter before 4, the framework did not have the ability to run console scripts bypassing the front controller and it looked like this 
php index.php controller method params

Starting from version 4, it became possible to create a cli() route, as well as run through spark.
In my opinion, the next stage of development will be to abandon the use of the cli() route and switch to only running console scripts through spark.
Now, using the cli route or spark, we load the entire core of the framework. Instead of directly accessing the class that is executed in the console, we load classes: Request - no payload, Response - meaningless for cli, filters, helpers, cache, web part routes.
What if we move the launch of console scripts to a separate core? It will only load the necessary functionality to run the script without all of the above, which is necessary for normal web routes to work.

spark --> console core  <-- base app init --> web core <--- HTTP
                      |                                                                      |
          run console script                                Request, Response, filters, routes, etc
                                                                             run web controller

I'm not sure removing `php index.php controller ...`access could be accepted by users.
Because all historical cli scripts as controllers will be unusable in v5.0.

But it seems no problem to change spark workflow and make it simple.

To be honest, @iRedds 's suggestion is what I initially expected of the CLI component when I first looked at the code. Separation of the web route and console route is a +1 for me.

It seems to me that the documentation section "Running Controllers via CLI" and CLI routing should be marked as deprecated with a suggestion to move controller logic to commands.

(This post was last modified: 06-07-2022, 01:40 AM by kenjis.)

I don't think dropping old functions is good, because migration cost from CI3 will be increased.

But recommend in the docs to use Spark commands is no problem.
And making old function code like Running Controllers via CLI, Auto Routing Legacy be decoupled and can be easliy disabled (and removed if most users want) is good.

I don't think dropping old functions too...

Amputation is sometimes necessary to save a person's life.
If you maintain inefficient code, then in the end it will create more problems.

For example, the CLIRequest class. There is no sense in it, but it is needed for the "HTTP" CLI.
But because of the support of this class, you have to take it into account when designing functionality related to queries. Extra, useless hemorrhoids.

The cost of migration should be to improve the performance and quality of development.
Yes, you can create conditions for a transitional period, but it is wrong to make an idee fixe out of this.

Why am I talking about marked as deprecated?
Because everyone takes the path of least resistance. And if it's just recommended, then 99% of CI developers will just ignore it.

@iRedds Thank you for your interesting opinion.
It has some valid points, but I'm not sure which way should we go.

But I agree that we should not use "Running Controllers via CLI",
and it is creating more problems.

@kenjis I want to try extracting Spark command calls from the CodeIgniter class.
More precisely, I already did it, but deleted it because of doubts that they would mark it as BC and that would be the end of it.
[Image: pZz9Zj2tPCrmHXwLFtwOd5dM1r0F5O1tJEBsNxeG...type=album]

Therefore, I would like to take this opportunity to find out in advance. Does it make sense for me to suggest this or not?

I think extracting Spark command calls from the CodeIgniter class is very good!

Spark command has nothing to do with Routing, Filters, and CI3.
It seems to me it is possible to make the change in v4.x.
In 5.0, I think it will be surely accepted.

If the existing spark commands do not break, I think okay.

I'm not sure other members agree with me.

Theme © iAndrew 2016 - Forum software by © MyBB