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

Skip to content

[HttpKernel] Missing Finder component #13810

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
RomanShumkov opened this issue Feb 27, 2015 · 6 comments
Closed

[HttpKernel] Missing Finder component #13810

RomanShumkov opened this issue Feb 27, 2015 · 6 comments

Comments

@RomanShumkov
Copy link

HttpKernel component depends on finder component, which is not listed in require section of composer.json.

As a result when running console application based on FrameworkBundle and HttpKernel component there is following fatal error:

Fatal error: Class 'Symfony\Component\Finder\Finder' not found in /usr/src/censored/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php on line 177

    public function registerCommands(Application $application)
    {
        // ...
        $finder = new Finder();
        $finder->files()->name('*Command.php')->in($dir);
        // ...
    }

@wouterj
Copy link
Member

wouterj commented Feb 27, 2015

It only depends on Finder for a very specific use case: Registering commands. Many applications using the HttpKernel standalone don't need this feature. That's why it's in the suggests section instead (it isn't required for basic usage).

Furthmore, I would not advise you to use any bundle outside of the framework.

Btw, this issue will probably be fixed by #9406

@RomanShumkov
Copy link
Author

@wouterj, I agree that registering commands is a very specific use case for HttpKernel, but on the other hand, I don't expect fatal errors from composer-managed package, when suggested dependency is not installed.

After some deeper investigation looks like it is FrameworkBundle who needs hard dependency on Finder, since FrameworkBundle is using commands registration, provided by abstract class in HttpKernel.

Furthmore, I would not advise you to use any bundle outside of the framework.

IMO, this suggestion defeats the purpose of splitting symfony into components, bridges and bundles.

@ghost
Copy link

ghost commented Feb 28, 2015

@RomanShumkov : agreed about the suggsted dependency problem, but i disagree about the splitting comment.

Bundles are generally framework specific by definition (not the case with WebProfiler). The components and bridges are split out to be reused.

@wouterj
Copy link
Member

wouterj commented Feb 28, 2015

I agree that registering commands is a very specific use case for HttpKernel, but on the other hand, I don't expect fatal errors from composer-managed package, when suggested dependency is not installed.

I agree that there are some things that should be improved. I propose:

  • Make sure there is no fatal error when a suggested package is not installed. Instead, throw a custom exception with a better description.
  • Add explaination to the suggest section to explain when the suggested packages are required

IMO, this suggestion defeats the purpose of splitting symfony into components, bridges and bundles.

No, exactly the oposite: It is a result of this great decoupling. Due to this decoupling, components and bridges are designed to work standalone. It's the bundles which are designed to integrate this standalone libraries into the Symfony Framework. Without this decoupling, everything would have been coupled to the framework. Now, just the bundles are.

@RomanShumkov
Copy link
Author

Not sure if we have the same understanding of what framework is :)

For me it's symfony/symfony package and that's why I was surprised by advice of not using bundles outside of the framework . Having dependency on entire symfony/symfony package looks like overkill, when creating/using simple bundle, e.g. for exposing existing non-sf2 application services over the web or command line interface.

In theory, bundle is just a plugin/extension point for handling requests using kernel, so having dependency on HttpKernel or FrameworkBundle should be enough, when things like persistence, logging, security etc, are already implemented outside of the bundle (possibly in non-sf2 way).

If however suggestion was about depending on FrameworkBundle, just ignore my previous comment.

Make sure there is no fatal error when a suggested package is not installed. Instead, throw a custom exception with a better description.
Add explanation to the suggest section to explain when the suggested packages are required.

@wouterj, +1
Also would be great to know supported versions of Finder component from suggestion and/or exception message.
Having Finder as a required dependency of FrameworkBundle would be even better, since console applications based on FrameworkBundle are using Finder for finding console commands within bundles.

@nicolas-grekas
Copy link
Member

It is very common for a package to "fatal error" when you use a feature that require you to load a suggested package (not symfony specific at all). Having a nice error message is a nice to have but it can't be enforced and require great case by case care and it will certainly be hard if not impossible to enforce these errors everywhere they could be usefull on the long run.
I'm thus closing. Feel free to open PRs if you spot good "missing dep" reporting candidate points.

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

No branches or pull requests

4 participants