-
Notifications
You must be signed in to change notification settings - Fork 11
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
Unable to reference PHP DI dependencies in Symfony 3.1 #16
Comments
First of all yes you have to use So the second example sounds correct. Now yes in Symfony all service IDs are turned to lower case. I don't remember that being a problem because in PHP class names are case insensitive, and it should be covered by the tests of this package. So in the end did the last example work? If not, what error did you get? |
See here: https://github.com/PHP-DI/Symfony-Bridge/blob/master/tests/FunctionalTest/Fixtures/config/class1.yml This test uses the same notation as you. And I just realize the documentation is wrong so that's maybe what mislead you: http://php-di.org/doc/frameworks/symfony2.html#using-symfonys-services-in-php-di
The |
The `@` was missing to mark the argument as a service reference. Reported in PHP-DI/Symfony-Bridge#16
Hmm, your suggestion about the case sensitivity is correct, I think. However, I still get Thanks for the quick update of the documentation! Stack trace:
|
Mmh if it's "sometimes" then it might be a cache issue indeed, or maybe related to a specific machine? Anyway if you can isolate a specific problem feel free to reopen an issue, the best thing is to have a reproducible test case or something similar. |
Hi! I've faced the same problem and have figured out why it is happening. The current test gives us false-positive result. It happens because the class names in PHP are case-insensitive, so class_exists('camelcaseclass') returns true if CamelCaseClass exists. But if we use autoloader and the appropriate class has not been loaded before calling class_exists, than class_exists('camecaseclass') will return false because of unix filesystem case-sensivity (it will look for the file called "camelcaseclass.php", which is actually missing, instead of the correct "CameCaseClass.php"). Thereby, when we use the class name in the dependencies of the service defined in the Symfony container, the dependency id is strtolower'ed. That causes the autoloader to look for the incorrect file when the php-di tries to resolve the dependency. There are two ways of making the test work properly. The first is moving the test itself (symfonyGetInPHPDI) to the very top of the TestCase file. The second is to use different classes in the tests. |
Ohh that's a nasty bug, thanks @Fedott for the details. I'm reopening this, I won't have time to look at this this week-end but feel free to send a pull request, even if it's just to add a test that reproduces the problem it will be useful. |
First of all, thank you for this very useful bridge!
I am trying to use the Symfony bridge with Symfony 3.1, but I ran into an issue where I seem to be unable to reference to PHP DI dependencies from the Symfony
services.yml
configuration file.This is my
services.yml
configuration file (as suggested in the docs):The signature of the
PageLayoutExtension
constructor ispublic function __construct(PageLayoutFactory $pageLayoutFactory, ContentBlockService $contentBlockService)
This configuration yields the following error:
Upon inspection, this error is caused by this line in
appDevDebugContainer.php
:Which makes the error obvious. This line should read:
Looking into the issue, I came across the following suggested modification of
services.yml
(forgot where I read it):However, this makes that same
appDevDebugContainer.php
line translate to:(Note the lowercase service names). Which is clearly wrong as well.
Am I missing something or is this new "functionality" of Symfony's container? Are there any workarounds?
The text was updated successfully, but these errors were encountered: