Skip to content

[Framework] Read env var SYMFONY_IDE by default for framework.ide #44575

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
Dec 13, 2021

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Dec 11, 2021

Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

Choosing an IDE is a personal preference, it should not be a project configuration (doc). In a team, each developer can use a different IDE, and a developer generally uses the same IDE on all their projects.

To setup a system-wide config, it is possible to update xdebug.file_link_format in php.ini. But that have to be done on every php version installed or any docker image; and we miss the shortcuts provided by Symfony.

My proposition it to read an environment variable that can be set by the developers in their user profile or in .env.local. The name SYMFONY_IDE can be discussed.

I currently uses the following config:

framework:
    ide: "%env(string:default::SYMFONY_IDE)%"

@carsonbot carsonbot added Status: Needs Review DX DX = Developer eXperience (anything that improves the experience of using Symfony) Feature labels Dec 11, 2021
@carsonbot carsonbot added this to the 6.1 milestone Dec 11, 2021
@carsonbot carsonbot changed the title [DX][Framework] Use env var to set framework.ide [Framework] Use env var to set framework.ide Dec 11, 2021
Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

That's a small but great one, love it!

@fabpot
Copy link
Member

fabpot commented Dec 13, 2021

@GromNaN Can you have a look at the broken tests (the ones broken by this PR)?

@GromNaN GromNaN changed the title [Framework] Use env var to set framework.ide [Framework] Use env var SYMFONY_IDE as default for framework.ide Dec 13, 2021
@GromNaN GromNaN changed the title [Framework] Use env var SYMFONY_IDE as default for framework.ide [Framework] Read env var SYMFONY_IDE by default for framework.ide Dec 13, 2021
@GromNaN GromNaN merged commit 23f374b into symfony:6.1 Dec 13, 2021
@GromNaN GromNaN deleted the ide-env branch December 13, 2021 20:36
@GromNaN
Copy link
Member Author

GromNaN commented Dec 13, 2021

I was about to open a PR on symfony/recipes@4cabf21, but according to the readme I must wait for the next version to introduce a new way of doing thing. Which is useless since this will be the default behavior in Symfony 6.1.

@wouterj
Copy link
Member

wouterj commented Dec 13, 2021

Yes, which is great news: You just avoided boilerplate code by adding great defaults :)

For context: As e.g. the Fast track book and SymfonyCasts relies on Flex recipes, they must be kept reproducible. Even if this means that we can't backport new best/cool practices to older versions.

@ostrolucky
Copy link
Contributor

Looks like there is an issue here, doctrinebundle tests are failing since this change https://github.com/doctrine/DoctrineBundle/runs/4571836311?check_suite_focus=true

@GromNaN
Copy link
Member Author

GromNaN commented Dec 19, 2021

Thank you for reporting this issue. Here is a proposed fix : doctrine/DoctrineBundle#1448

The tests cases are registering the framework configuration without the compiler pass; which is not a use case for which we promise backward compatibility.

GromNaN added a commit that referenced this pull request Mar 17, 2022
…exception in case of fatal error (GromNaN)

This PR was merged into the 6.1 branch.

Discussion
----------

[ErrorHandler][HttpKernel] Read SYMFONY_IDE to render exception in case of fatal error

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

In #44575, the env var `SYMFONY_IDE` is read when `framework.ide` is not set. This works to format links in most runtime exceptions. But fatal errors that occurs before application boot  are not rendered using this config (ex: syntax error in service class).

Since the env var is globally available, it can be read even if it's not been injected.
The list of IDE formats have been duplicated from [`FileLinkFormatter`](https://github.com/symfony/symfony/blob/8e8207bb72d7f2cb8be355994ad2fcfa97c00f74/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php#L27-L35).

The update of `Symfony\Component\HttpKernel\Debug\FileLinkFormatter` is not necessary for my use-case, but for exhaustivity.

Commits
-------

03ad4af Read SYMFONY_IDE to render exception in case of fatal error
@fabpot fabpot mentioned this pull request Apr 15, 2022
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Mar 23, 2023
This PR was merged into the 6.2 branch.

Discussion
----------

update default value for framework.ide

The default value was changed in symfony/symfony#44575

Commits
-------

9636026 update default value for framework.ide
weaverryan pushed a commit to symfony/symfony-docs that referenced this pull request Mar 28, 2023
This PR was merged into the 6.2 branch.

Discussion
----------

update default value for framework.ide

The default value was changed in symfony/symfony#44575

Commits
-------

9636026 update default value for framework.ide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) Feature Status: Reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants