Skip to content
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

[make:entity] Suggestion: Add link in output that opens the file directly in my IDE #1003

Open
ThomasLandauer opened this issue Oct 30, 2021 · 2 comments

Comments

@ThomasLandauer
Copy link
Contributor

I'm suggesting to change this line after php bin/console make:migration:

Next: Review the new migration "src/Migrations/Version20211030130836.php"

to

Next: Review the new migration phpstorm://open?file=/.../src/Migrations/Version20211030130836.php

... if Symfony's ide option is set: https://symfony.com/doc/current/reference/configuration/framework.html#ide

The line is generated at MakeMigration::generate().

If you (a) think that this is good idea, and (b) ask me to come up with a PR ;-) I have two questions:

  1. How can I get the ide configuration value from inside MakeMigration?
  2. How can I convert the relative filename (coming from $this->getGeneratedMigrationFilename($migrationOutput);) to an absolute path? I think this comes down to: How can I get %kernel.project_dir% to prepend it?

I committed a similar feature to phpstan and Codeception.

And a related feature has already been added in #559 - but I'm not sure what it does exactly.

@weaverryan
Copy link
Member

I definitely like this idea :). Yes, the MakerLinkFormatter - https://github.com/symfony/maker-bundle/blob/main/src/Util/MakerFileLinkFormatter.php - already has the complex parts of this. We use it currently when we output that we "wrote" to a file -

$this->makerFileLinkFormatter->makeLinkedPath($absolutePath, $relativePath)

But, you could certainly use this for make:migration - that would be great (i constantly go an open these files right after I create them). The service id is maker.file_link_formatter. We may still need to connect a few pieces, but hopefully this is enough :).

@ThomasLandauer
Copy link
Contributor Author

ThomasLandauer commented Nov 17, 2021

Oops, we have a general problem here! There are two "standards" on how to display links in a console:

  1. Old-fashioned: Display this text verbatim: phpstorm://open?file=/.../src/Migrations/Version20211030130836.php, and then rely on the terminal's auto-detection to make it clickable. This is (as far as I know) supported by every terminal.
  2. Fancy (i.e. HTML-like): Add some special characters to allow displaying a different link text. This is supported by some terminals: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

What I suggested (and what I've added to PHPStan) is (1). What makeLinkedPath creates is (2).

I don't know how the adoption of (2) will progress. But for Konsole (=default in KDE) it doesn't look too good: https://bugs.kde.org/show_bug.cgi?id=379294
And (frankly) I'm also not sure if it's a good idea at all...

Anyway. In order to get this to work for everybody, I see two ways:

  • Switch to (1) completely, i.e. modify OutputFormatterStyle
  • Introduce a configuration parameter to let the user decide.

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

No branches or pull requests

2 participants