-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
Add debug:component
command
#1088
Add debug:component
command
#1088
Conversation
d103520
to
d67f8bd
Compare
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.
This is great work @StevenRenaux!
Couple things:
- In the listing of components, could you add a Live? (yes/no) column?
- When showing details about a component, can you indicate whether it is live or not?
- Also in the details, can you list the live props?
|
@kbond I will try to work on your suggestions
|
Sounds good!
I think this is available in the metadata (has a |
Hi @kbond I updated the code with your suggestions. For one component :
And for all :
|
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.
Whoooo thanks a lot for it @StevenRenaux! 🧡
@@ -34,6 +34,7 @@ | |||
"twig/twig": "^2.14.7|^3.0.4" | |||
}, | |||
"require-dev": { | |||
"symfony/console": "^5.4|^6.0", |
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.
Is it the right place to add this command? Maybe in the StimulusBundle?
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.
Doesn't know either and it's the reason why i putted here
$class = $metadata->get('class'); | ||
$allProperties = []; | ||
|
||
if ($class) { |
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 think it can be useful to display:
- properties with the ExposeInTemplate attribute, and if the name is set show the name.
- if the component has a mount, premount, and postmount hooks
And for LiveConponents:
- as @kbond said show if the components is live
- show live props
- show live actions
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.
Hi @WebMamba and @kbond, an update with Events
and LiveAction
, it could be look like this for a Live component:
$ php bin/console debug:component RandomNumber
+--------------------+-----------------------------------+
| Property | Value |
+--------------------+-----------------------------------+
| Component | RandomNumber |
| Type | AsLiveComponent |
| Class | App\Components\RandomNumber |
| Template | components/RandomNumber.html.twig |
| Properties | string $name = toto |
| | string $type = test |
| Live Properties | int $max = 1000 |
| | int $min = 10 |
| Events | Mount |
| | PreMount |
| LiveAction Methods | resetMax |
+--------------------+-----------------------------------+
And for a TwigComponent
$ php bin/console debug:component Coucou
+------------+-----------------------------+
| Property | Value |
+------------+-----------------------------+
| Component | Coucou |
| Type | AsTwigComponent |
| Class | App\Components\Alert |
| Template | components/Coucou.html.twig |
| Properties | string $type = success |
| | string $message |
| Events | Mount |
| | PreMount |
+------------+-----------------------------+
But for the #[ExposeInTemplate]
what could I render for you?
The name of the property in the class or the one one displayed in the template? And with the getter or not?
31fc8b8
to
dd1121f
Compare
The issue with using these attributes is components can be registered without (ie 3rd party bundle registering components purely with a tag). |
963bc37
to
4defd26
Compare
Updated as you submitted ;) |
If you want components with a specific dir:
|
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.
This is cool! Though, tbh, it makes me wish we had more centralized ways to get metadata about a component. It feels like we are reimplementing a lot of logic - like for finding what public properties will be made into variables, etc.
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.
Agree with Ryan there's a lot of duplication but this can be refactored to some kind of metadata registry.
We should probably do this sooner, rather than later so things don't get out of sync. For now, it's out of the scope of this PR.
Yes I was thinking the same thing when I read for the first time this PR. Thanks @StevenRenaux for digging into all of this |
Ok then. But I'll be watching for some PR's to centralize some of that stuff ;). @StevenRenaux Can you fix the conflict? I can usually do that with our merge tool, but the rebase is looking oddly ugly. |
@weaverryan Conflict resolution done and let me know when it will be done and I will update this command 😉 |
9725943
to
9d2108b
Compare
Thank you for your hard work Steven and congrats on this great PR. I forgot that I hadn't merged it yet, and I was needing it yesterday and trying to use it. So today my work will be better ;) |
Related to the Future Ideas section of #102
I added a debug:component command.
Debugging component
The
debug:component
command lists all your application components (TwigComponent and LiveComponent) who lives in templates/components directory:Pass the name of some component to this argument to print the component details:
To get the details about an anonymous component who is rendered with sub directory, just add it to the name: