-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix mvc bootrapping #110
base: 1.9.x
Are you sure you want to change the base?
Fix mvc bootrapping #110
Conversation
b2f1c53
to
5df98bc
Compare
optional via $appConfig['laminas-cli']['bootstrap_mvc_application'] Signed-off-by: Falk Hermann <[email protected]> Signed-off-by: Falk Hermann <[email protected]>
Signed-off-by: Falk Hermann <[email protected]> Signed-off-by: Falk Hermann <[email protected]>
Signed-off-by: Falk Hermann <[email protected]> Signed-off-by: Falk Hermann <[email protected]>
Signed-off-by: Falk Hermann <[email protected]> Signed-off-by: Falk Hermann <[email protected]>
5df98bc
to
794e80a
Compare
|
||
if ($appConfig['laminas-cli']['bootstrap_mvc_application'] ?? false) { | ||
// initialize & bootstrap MVC Application | ||
$mvcApplication = Application::init($appConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current class is a container resolver and not an application initializer. Maybe another listener for the console application would be a better place for this task. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not arguing here, but couldn't a similar argument currently be made regarding the whole module loading?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without loading the modules, you will not get the container configuration from the individual modules, which means that the entire container will not be resolved correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides my previous comment, which ConsoleEvent
could be used for initializing the MvcApplication
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can find the available events with description here: https://symfony.com/doc/current/components/console/events.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right. I did not do this to keep it BC.
loadModules()
is already it this place and is part of::init()
, too- moving the old code (the half App initialization) to a different place, changes the execution order and might cause a BC break
- separating the "old-way" from "the-new" way to two separate places would require checking the option in two places ... that's a dangerous thing to do, imo. And changes execution order, too, in case you wan't to use the ::init().
This being said: In a release that is allowed to break BC I agree that the whole MVC Init should be outside of the Resolver. ( Including loadModules()
, imo ). But with this there would be a lot more to do.
For this quick fix, the best is to keep the footprint small and change as little as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this quick fix…
We want a correct solution, anything else means pushing the problem into the future and touching it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And please note, I wrote "maybe". That means it is not the solution or even the correct solution. That was just the first thought that came to my mind when I saw the names. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally legit. Any thoughts are welcome. :-)
That's what I can offer for now. I'd like to write a more clean solution but this will not happen within the next few days. Maybe someone else can hop on earlier.
I like it. Regarding the
Is there currently a way to tell if we are in a laminas-cli run context? Would it maybe make sense to define a namespaced const in define('Laminas\Cli\RUN_CONTEXT', true); So that a hypothetical public function onBootstrap(EventInterface $e)
{
// do general purpose bootstrapping
if (defined('Laminas\Cli\RUN_CONTEXT')) {
return;
}
// do http-only bootstrapping
} I'm just spit-balling here. 😅 |
Pollution of the global namespace is not an option and must be avoided. |
That's why I was specifically talking about a namespaced constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless of the patch direction, I expect tests to verify what's being done here.
Not AFAIK. But: This should not be necessary. As told in the documentation you should not do any heavy stuff in If you've got something that really should not be executed in cli context but is currently located in ... but that's OT and should be diskussed in the Forum. |
May i 'expect' your help on this, @Ocramius? I don't know how to set up an environment for the test. And I've no time to figure it out, atm. I tried some bits, without success. I'm not familiar with the used vfs and don't want to mess the tests up by introducing something totally different. |
@FalkHe |
I created a failing test case for the original issue. https://github.com/steffendietz/laminas-cli/tree/failing-testcase-for-106 What are your requirements for a correct solution? |
I would rather prefer Mvc application to provide Bootstrapping Mvc unconditionally is not something I am comfortable with. That is a decision that needs to be made consciously for every specific application. |
Indeed. My bad. |
Description
Provide option to enable MVC Application bootstrapping.
False by default, to not break any existing app.
See Issue #106 .