Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WebProfilerBundle] remove definitions when they are not usable #26115

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

Closed
wants to merge 1 commit into from

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Feb 9, 2018

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

@stof
Copy link
Member

stof commented Feb 9, 2018

Is anything usable in WebProfilerBundle if you don't have Twig ? I don't think so.

@stof
Copy link
Member

stof commented Feb 9, 2018

WebProfilerBundle should have a requirement on TwigBundle, not just on Twig. It would solve the issue cleanly in a Flex world when people install things separately.

@xabbuh
Copy link
Member Author

xabbuh commented Feb 9, 2018

Probably not, but this at least prevents the cache:clear call from breaking.

@stof
Copy link
Member

stof commented Feb 9, 2018

I think the reason to do it this way was to enable usage of the WebProfilerBundle code in Silex without bringing FrameworkBundle. But TwigBundle no longer depend on FrameworkBundle. The only dependency that TwigBundle has and WebProfilerBundle does not have is symfony/config (which won't hurt in the context of Silex, and is necessary in the context of Symfony anyway)

@xabbuh
Copy link
Member Author

xabbuh commented Feb 13, 2018

@fabpot What do you think? Is it okay for you to add the TwigBundle requirement?

@fabpot
Copy link
Member

fabpot commented Feb 19, 2018

The profiler does not need the bundle, just plain Twig as demonstrated in Silex. I would not add the bundle as a hard requirement. That being said, I can see that with Flex, more and more people have problems with this (even if using composer req profiler does the right thing).

Not sure what to do here.

@xabbuh
Copy link
Member Author

xabbuh commented Feb 20, 2018

In that case, just removing the invalid definitions as done in this PR should improve DX as clearing the cache afterwards shouldn't fail anymore.

@stof
Copy link
Member

stof commented Feb 20, 2018

Well, it needs the bundle to have a working twig service (which is what the bundle is doing).

Regarding the usage in Silex, TwigBundle does depend on FrameworkBundle anyway, so having it as a dependency would not bring all of symfony anymore (it has the same dependencies than WebProfilerBundle)

$container->removeDefinition('web_profiler.controller.exception');
$container->removeDefinition('web_profiler.controller.profiler');
$container->removeDefinition('web_profiler.controller.router');
$container->removeDefinition('web_profiler.debug_toolbar');
Copy link
Member

Choose a reason for hiding this comment

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

Removing all these makes the bundle useless, as the only goal of the bundle is to provide the UI to access the profiler data.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but at least clearing the cache does not fail now. I don't care which solution we choose, but anything is better DX-wise than the current behaviour.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Apr 14, 2018

A way to solve this would be to allow Flex to replace a package by a pack that would be auto-unpacked:
composer require symfony/web-profiler-bundle => flex replaces by profiler-pack (or another smaller pack that has the bare minimum to make this work in a Flex managed context) + auto-unpacks the pack.

This PR looks like a workaround/hack for a missing behavior in Flex.

@xabbuh
Copy link
Member Author

xabbuh commented Apr 14, 2018

To be fair, this is not limited to Flex but you would observe the same behaviour when installing the package manually using Composer without Flex.

@nicolas-grekas
Copy link
Member

same behaviour when installing the package manually

but then it's your responsibility to fix your dependencies

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Apr 29, 2018

So, shall we do this until symfony/flex#360 is implemented? WDYT?

@fabpot
Copy link
Member

fabpot commented May 30, 2018

First, WebProfilerBundle never had a dependency on FrameworkBundle, so that's not the reason (and TwigBundle never had a dependency on FrameworkBundle either).

But thinking about this one again, I've changed my mind and I think that we can add TwigBundle as a dependency. Let's do it for 4.2 as Silex won't be maintained anymore when it will be released.

See #27417

fabpot added a commit that referenced this pull request May 30, 2018
…dency (fabpot)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[WebProfilerBundle] Make Twig bundle an explicit dependency

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26115
| License       | MIT

Let's make Twig bundle an explicit dependency of WebProfilerBundle. That's better for DX and as Silex won't be maintained when 4.2 is out, it's the right time to do so.

Commits
-------

cac37ca [WebProfilerBundle] made Twig bundle an explicit dependency
@xabbuh xabbuh closed this May 30, 2018
@fabpot
Copy link
Member

fabpot commented May 31, 2018

Don't you think that throwing an exception would be better?

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.

5 participants