-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Implement lazy-loading of cli commands #419
Conversation
Codecov Report
@@ Coverage Diff @@
## master #419 +/- ##
============================================
+ Coverage 84.35% 84.38% +0.02%
- Complexity 8722 8737 +15
============================================
Files 1188 1192 +4
Lines 29671 29726 +55
============================================
+ Hits 25029 25083 +54
- Misses 4642 4643 +1
Continue to review full report at Codecov.
|
@vladgorenkin It breaks BC. Therefore, we can only accept at v2.9 In addition, I don't really want to be tied to agreements with "magic constants". However, I understand that this style has already been adopted in Spiral 2.x and should be followed. |
In what way? Dependency on LazyCommand? No problem in waiting till 2.9 though, no hurry here.
I absolutely agree, I do not like magic solutions either although it seemed to me as the most suitable taking into account existing logic. This solution was also partly inspired by Symfony's way of declaring lazy commands (by declaring $defaultName property static). The problem is we need to extract name and description of a command to register it in Application so NAME and DESCRIPTION need to be public. If you have any better solution in mind please let me know. |
Yep. This requires bringing up a version of the Symfony's components. There is no such thing now: https://github.com/spiral/framework/pull/419/checks?check_run_id=2772546255 |
6c44196
to
63962d8
Compare
@vladgorenkin Can you raise a version of the symfony dependencies to pass all the tests? |
✔️ |
This is not quite the correct way. When the build starts, everything will break. The final composer file is built from all existing packages using Thanks anyway. This is not critical, I will fix everything when I do (merge) this PR. |
f98ef07
to
36c1697
Compare
36c1697
to
8aab1a6
Compare
Just for the sake of my own education tried to resolve conflicts and generate composer.json per your instructions. Would you have a look and tell me if everyhing is ok? |
Yes. 👍 I see that there are problems with |
This PR implements lazy-loading of CLI commands to prevent unneeded commands from being constructed. This speeds up CLI initialization and solves situations when one command's dependency breaks all other commands (e.g. a command whose dependency uses result of ORM query will break migrate:init when no migrations were applied).
Lazy-loaded command declaration is done through upgrading
Command::NAME
's visibility to public so locators can extract command's name (and optionaly description) from command without constructing it.Example: