8000 [FrameworkBundle] Added about command by ro0NL · Pull Request #19278 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Added about command #19278

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

Merged
merged 1 commit into from
Mar 22, 2017
Merged

[FrameworkBundle] Added about command #19278

merged 1 commit into from
Mar 22, 2017

Conversation

ro0NL
Copy link
Contributor
@ro0NL ro0NL commented Jul 3, 2016
Q A
Branch? "master"
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets comma-separated list of tickets fixed by the PR, if any
License MIT
Doc PR reference to the documentation PR, if any

image

@ro0NL ro0NL changed the title poc kernel:info command [FrameworkBundle] kernel:info command Jul 3, 2016
@linaori
Copy link
Contributor
linaori commented Jul 3, 2016

Could additionally also display the cache and log dirs here.

@hhamon
Copy link
Contributor
hhamon commented Jul 3, 2016

Nice one!
To be consistent with other commands, I would change the name to debug:kernel ;)

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 3, 2016

debug:kernel is just fine i guess. Btw fabbot.io is wrong?

@hhamon
Copy link
Contributor
hhamon commented Jul 3, 2016

See the fabbot.io patch.
http://fabbot.io/report/symfony/symfony/19278/76811f35f3e69377ef8298546259bc15b0791b60
You inversed the type and var name in the @param phpdoc section.

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 3, 2016

Nah it's the inline @var... afaik this is the way to typehint inline variables.. =/

return new \DateTime() > \DateTime::createFromFormat('m/Y', $date);
$date = \DateTime::createFromFormat('m/Y', $date);
$date->modify('last day of this month');
$date->setTime(23, 59, 59);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works too: last day of this month 23:59:59

@linaori
Copy link
Contributor
linaori commented Jul 3, 2016

What if you try /** @var $foo Bar */?

@ro0NL ro0NL changed the title [FrameworkBundle] kernel:info command [FrameworkBundle] The debug:kernel command Jul 3, 2016
@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 3, 2016

Last thing i could think of is adding some PHP / caching / platform info.. but other then that.. i like it :)

@dunglas
Copy link
Member
dunglas commented Jul 3, 2016

Nice improvement! Can you add tests for this new command?

@fabpot
Copy link
Member
fabpot commented Jul 4, 2016

Before reviewing the code, I'm wondering which problems it solves? What's the added value? Symfony already has quite a few built-in commands, so adding a new one should be considered carefully, it should add some value. Here, why and when would I use this command?

@linaori
Copy link
Contributor
linaori commented Jul 4, 2016

I would mainly use this command to have a "CLI WDT" for applications that do not have pages that are able display the WDT; APIs and Command Line related (e.g. cron).

Additionally, options could be passed along to only display a certain setting. This way you can easily collect a lot of info of multiple applications at once. This is great when trying to streamline applications. As my company has at least 15 applications running at all times, it would make finding inconsistencies between kernels easier. It would also help detect which bundles we use in which environment and easily compare without having to check different source files.

Just my 2 cents of why I'd like to have this feature.

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 4, 2016

For me; i want to leave the CLI as little as possible. Not want to dive into code / visit websites to get some (version) specifications. Also consider a environment where colleagues have their own workingcopy, docker container etc. I want to debug/review/troubleshoot their setup in a blink of an eye.

Besides that, it's definitely nice to have, which always counts for value imo.

edit: @iltar even the WDT doesnt expose all information like EOL, EOM etc. ;-) Ie. i would also like to see this info from there (different story ;-)).

@mickaelandrieu
Copy link
Contributor

@ro0NL I don't realy see the value of this command in the framework. How about make a Bundle to share this command ? If you have a lot of Symfony websites to manage, could be nice to return theses useful informations into a dashboard :)

What do you think ?

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 5, 2016

A whole bundle for 1 command is a bit much :) but i'm really not a package maintainer or so. If it's not accepted, and you like, it's here to take 👍

Anyway, why it should be accepted :) These are framework specs, numbers, etc., hence the framework should also expose them, preferably from the CLI (imo). But yes, also from the WDT as some specs may differ (however that's not what this PR is about).

Basicly it's about, is the info useful enough yes/no. I would say yes, (for me) especially when entering someone else's application (work, opensource "editions", my environment, docker environments, etc.) to get a quick scan of whats going on. I.e. big 👍 for me if i can do this in whatever symfony (full-stack) application.

We could argue this needs a dedicated command vs. bin/console -V --verbose.

/**
* @var string
*/
private $baseDir;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this prop is legitimate. Looking at the code, you should inject the value as an argument to formatPath instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Done.

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 6, 2016

Maybe we should explicitly split symfony specs from kernel specs (although code-wise it's all kernel related, stuff like Kernel::VERSION is basicly about symfony).

image

ping @stof

@linaori
Copy link
Contributor
linaori commented Jul 6, 2016

The bundle list looks really chaotic, have you tried what it would look like if you'd introduce a 3rd column for it?

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 6, 2016

Not sure =/

image

We could also do bin/console debug:kernel --with-bundles showing all bundles + info, making the table really long :)

@theofidry
Copy link
Contributor

I would be 👍 for the option, it's a bit that won't render well on small screens

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 6, 2016

image
could work

We can also leave the path out, and keep it a simple list. Perhaps later someone can enhance it with detailed bundle information.

@sh4ka
Copy link
sh4ka commented Jul 19, 2016

Excellent command. What do you think about adding a third horizontal separator for the directories? You have 'Symfony', 'Kernel', what about 'Directories'?

@ro0NL
Copy link
Contributor Author
ro0NL commented Jul 20, 2016

Not sure.. the directories are kernel metadata. The 2 lines separating directories and bundles was just my own creativity 👼 to create some form of grouping (of kernel metadata).

@ro0NL
Copy link
Contributor Author
ro0NL commented Nov 6, 2016

Final thoughts; Goal of this PR is to bring (more) parts of the WDT to the console.

Why?

  • Prefer console when possible (ref1, ref2)
  • Specific values could actually differ from web (ie. php.ini related)

How?

  • Add useful commands in the debug: namespace (imo. this represents WDT for console), ie. we have a lot already 👍
  • Basically this brings the WDT Configuration panel to the console..
Symfony / Framework
- Version / Version ID
- EOM / EOL

Kernel / Application
- Type / Name / Env / Debug
- Paths / Bundles

PHP / System
- Version
- Caching / Acceleration / Xdebug
- Charset / TImezone / Locale

Worth it?

@linaori
Copy link
Contributor
linaori commented Nov 6, 2016

One thing I often notice people having trouble with, is that Apache and CLI use a different php.ini, perhaps that could be listed in both the WDT and CLI?

@ro0NL
Copy link
Contributor Author
ro0NL commented Nov 6, 2016

You mean to reference the path to php.ini somewhere?

@javiereguiluz javiereguiluz added this to the 3.2 milestone Nov 7, 2016
@ro0NL
Copy link
Contributor Author
ro0NL commented Nov 13, 2016

Updated to

image

@fabpot
Copy link
Member
fabpot commented Nov 13, 2016

Reading the output of the command, it looks like it's more about the config than debug, right?

@ro0NL
Copy link
Contributor Author
ro0NL commented Nov 13, 2016

More or less..., i guess its main purpose is to debug while it's actually showing config. What do you propose?

I just had this wild idea of a global about command.. bin/console about that is.

@fabpot
Copy link
Member
fabpot commented Nov 13, 2016

Indeed, I like the about command better. What others think?

@javiereguiluz
Copy link
Member

I like about a lot!

@ro0NL
Copy link
Contributor Author
ro0NL commented Nov 13, 2016

Done. Love it.

Current command description is Displays information about the current installation. Is this ok?

F438

@ro0NL
Copy link
Contributor Author
ro0NL commented Nov 13, 2016

Also playing around with adding some git info (reading straight from .git/HEAD). WDYT?

image

image

@javiereguiluz
Copy link
Member

@ro0NL I don't have an opinion about your last proposal ... but I recommend you to not add any other feature to the command. Otherwise we won't be able to stabilize it on time for Symfony 3.2.

@ro0NL
Copy link
Contributor Author
ro0NL commented Nov 13, 2016

Agree. I wouldnt mind though if this becomes a longer table list in the future (i like specs :)), but we should consider each entry carefully.

Last but not least, im considering to remove the bundle paths. Not sure how useful those actually are 😕 it would cleanup the output a lot :)

It could be even a comma separated value perhaps, in case of many bundles.

@HeahDude
Copy link
Contributor

I would suggest to add "Base directory" without Git info, but renamed to "Root directory" which looks more like the "App directory".

@ro0NL
Copy link
Contributor Author
ro0NL commented Nov 13, 2016

Root is relative to the kernel group, ie. it reflects getRootDir. Not sure we should mix&match.. but agree this could be confusing.

Also reconsidered adding the base directory, you probably know where your project lives already.

@fabpot fabpot modified the milestones: 3.3, 3.2 Nov 16, 2016
{
$this
->setName('about')
->setDescription('Displays information about the current installation')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current project?

$baseDir = realpath($kernel->getRootDir().DIRECTORY_SEPARATOR.'..');
$bundles = array_map(function ($bundle) use ($baseDir) {
return '* '.$bundle->getName().' (<comment>'.self::formatPath($bundle->getPath(), $baseDir).'</>)';
}, $kernel->getBundles());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not list the bundles as there are easily accessible in the Kernel class.

array('Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'),
array('OPcache', extension_loaded('Zend OPcache') && ini_get('opcache.enable') ? 'true' : 'false'),
array('APCu', extension_loaded('apcu') && ini_get('apc.enabled') ? 'true' : 'false'),
array('Xdebug', extension_loaded('xdebug') ? 'true' : 'false'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Displaying this information can be misleading as it can be different from the PHP used by the web server. People should use php itself to get this information. I would restrict the information to what is really specific to Symfony.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shows the same info as WDT configuration panel does.. 🤔 which was the basic idea; to mimic this on CLI, so you can actually spot differences at first sight.

I dropped the bundle list (sounds reasonable), the version ID and an additional table separator.

image

I think it looks pretty clean :))

@ro0NL ro0NL changed the title [FrameworkBundle] The debug:kernel command [FrameworkBundle] Added about command Mar 22, 2017
@fabpot
Copy link
Member
fabpot commented Mar 22, 2017

Thank you @ro0NL.

@fabpot fabpot merged commit 2550eab into symfony:master Mar 22, 2017
fabpot added a commit that referenced this pull request Mar 22, 2017
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Added about command

| Q | A |
| --- | --- |
| Branch? | "master" |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | comma-separated list of tickets fixed by the PR, if any |
| License | MIT |
| Doc PR | reference to the documentation PR, if any |

![image](https://cloud.githubusercontent.com/assets/1047696/24218101/50c4ebe2-0f42-11e7-985d-b47fc8a6f520.png)

Commits
-------

2550eab [FrameworkBundle] Added about command
@ro0NL ro0NL deleted the frameworkbundle/kernel-info-command branch March 22, 2017 20:07
@ro0NL
Copy link
Contributor Author
ro0NL commented Mar 22, 2017

Awesome 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0