For some reason PHPStorm is not autocompleting it properly. When I hover over $this->container, it shows me: "Field 'container' not found in GenusController". I have both the Symfony2 plugin and PHP Annotations plugin installed and enabled. Is there some sort of a 'magic switch' to get it to work? I've marked the 'src' directory as Sources Root.
I think I know the problem. Also right-click on the var/cache directory and mark this as excluded. Before you did this, I bet that if you hovered over the word Controller (in extends Controller), you would have seen some message like "Multiple references found". The Controller class is cached in the var/cache directory (for performance), and this confuses PhpStorm and it quits auto-completing some things from Controller.
Let me know if this was the problem! No auto-complete is no fun :)
I've tried marking the var/caches folder as Excluded, but the issue remains. I've also chosen the Invalidate Caches option, but that doesn't seem to have any effect.
Also when i append 'extends Controller' next to a class statement, it automatically includes the file "Symfony\Component\HttpKernel\Tests\Controller" instead of "Symfony\Bundle\FrameworkBundle\Controller\Controller"
Ah, interesting! Usually, when you say "extends Controller", it would offer you *both* choices - the one from HttpKernel\Tests and FrameworkBundle (since these are both called Controller). Obviously, you should use the one from FrameworkBundle. But if the one from FrameworkBundle isn't being offered as a choice, then it seems that PhpStorm doesn't see it at all (which is especially weird). Assuming the app works, then the problem is definitely with PhpStorm and you're doing good things by Invalidation the cache. I would also try to browser directly to the path - in vendor/symfony/symfony/src/Symfony/Bundle to see if the file is there. You can right-click on any directory and select "Synchronize" to (hopefully) make PhpStorm see the files in the directory (though Invalidating the Cache is similar).
Hello I also have a problem with autocompetion. 1. I mark var/cache like excluded 2. check for be sure class Symfony\Bundle\FrameworkBundle\Controller\Controller exist
$funFact = $this->container->get('markdown.parser') when i write $this->container->(autocomplete show 'get' and other) then ->get( (here no autocomplete) )
Please, double check you have installed and *enabled* Symfony plugin in PhpStorm preferences for your project: press Command + , on Mac and type "Symfony" in search box. Then choose Languages and frameworks -> PHP -> Symfony and ensure you have checked all necessary boxes, especially the "Enable plugin for this project" one. After all, try to restart PhpStorm. Actually, it helps in most weird behaviors of PhpStorm :)
"$this->get()" in a controller is just a shortcut for "$this->container->get()". Open the Symfony\Bundle\FrameworkBundle\Controller\Controller::get() and you will see it yourself ;)
If you are getting transform method not implement error. Your composr download a dev version which does not have transform() method implemented.
Do the following: 1) Update composer.json under your project root directory "knplabs/knp-markdown-bundle": "^1.5", 2) run update in your terminal composer update knplabs/knp-markdown-bundle
Hi, i have this error: "You have requested a non-existent service "markdown.parser". I check and in my services list markdown is not present. How can I add it? Thank you.
markdown.parser seems to be having an issue getting recognized as a service and autocompleting for me. I have the symfony plugin and php annotations enabled for the project and autocomplete is working for other things.
In $this->get( ), when I start typing 'markdown' it suggests 'templating.helper.markdown', but no other services will autocomplete, but it won't find markdown.parser.
If I run ./bin/console debug:container markdown I see all the services which makes it even more confusing.
./bin/console debug:container markdown
Select one of the following services to display its information: [0] markdown.parser.min [1] markdown.parser.light [2] markdown.parser.medium [3] markdown.parser.max [4] markdown.parser.flavored [5] markdown.parser.parser_manager [6] templating.helper.markdown [7] doctrine_cache.providers.my_markdown_cache [8] markdown.parser >
When you do `$this->get('markdown.parsers');` does it throw an exception or something? If that's not the case and you are getting the correct object, it must be something related to PhpStorm settings, which version are you using? have you tried clearing the index? (inside settings->plugins->symfony)
Yeah, no exception so Symfony is finding it when things get executed, but PHP storm still says 'Missing service'. I've cleared the Symfony plugin index, invalidated the PHP storm caches.
Using php storm 2017.2.1. It looks like others have had a similar issue, so maybe it will just start working, who knows..
Soooo I had var/cache excluded from the beginning, per the recommendation in this course. However, when excluding var/cache PHP storm won't find any of my services. IF I cancel exclusion of that var/cache, now PHP Storm can find all my services and autocomplete works great...
Are you guys sure about excluding that directory? I'm fairly certain appDevDebugProjectContainer.xml is important for mapping services.
Or if you exclude var/cache maybe you need to manually map it?
In this SO thread it seems to be an important file, but I don't have a cache directory in my app folder, only in var/cache, should I? Or is this something symfony changed recently? https://stackoverflow.com/q...
Oh, it depends on the Symfony version you are using, I don't know when exactly they did that change (moving cache directory from app to var directory) but if you are using Symfony 3.* you need to adjust your symfony's plugin settings
Oh, really? I can't find any mention about the "markdown.helper" in script code: https://github.com/knpunive... and even in the video of this chapter. Do you mean "markdown.parser"? Could you point me to the script/video where we use the "markdown.helper", please?
Sorry, my bad, I meant "markdown.parser", and it's working. The PHP Symphony auto suggest initially offered me only the "templating.helper.markdown" option for some reason so it confused me. Now it's working.
when i want to add {{ funFact }} to the dd section in show.html.twig symfony throws this error: "Variable "funFact" does not exist in genus\show.html.twig at line 17"
the fetNotesAction function looks like this:
$funFact = 'Octopuses can change the color of their body in just *three-tenths* of a second!';
29 Comments
For some reason PHPStorm is not autocompleting it properly. When I hover over $this->container, it shows me: "Field 'container' not found in GenusController". I have both the Symfony2 plugin and PHP Annotations plugin installed and enabled. Is there some sort of a 'magic switch' to get it to work? I've marked the 'src' directory as Sources Root.
Hi Roy!
I think I know the problem. Also right-click on the var/cache directory and mark this as excluded. Before you did this, I bet that if you hovered over the word Controller (in extends Controller), you would have seen some message like "Multiple references found". The Controller class is cached in the var/cache directory (for performance), and this confuses PhpStorm and it quits auto-completing some things from Controller.
Let me know if this was the problem! No auto-complete is no fun :)
Thanks for your quick response ;-)
I've tried marking the var/caches folder as Excluded, but the issue remains. I've also chosen the Invalidate Caches option, but that doesn't seem to have any effect.
Also when i append 'extends Controller' next to a class statement, it automatically includes the file "Symfony\Component\HttpKernel\Tests\Controller" instead of "Symfony\Bundle\FrameworkBundle\Controller\Controller"
Ah, interesting! Usually, when you say "extends Controller", it would offer you *both* choices - the one from HttpKernel\Tests and FrameworkBundle (since these are both called Controller). Obviously, you should use the one from FrameworkBundle. But if the one from FrameworkBundle isn't being offered as a choice, then it seems that PhpStorm doesn't see it at all (which is especially weird). Assuming the app works, then the problem is definitely with PhpStorm and you're doing good things by Invalidation the cache. I would also try to browser directly to the path - in vendor/symfony/symfony/src/Symfony/Bundle to see if the file is there. You can right-click on any directory and select "Synchronize" to (hopefully) make PhpStorm see the files in the directory (though Invalidating the Cache is similar).
Let me know if you figure it out!
The Synchronize option seems to be improving the auto-complete issues at some moments.
Hello I also have a problem with autocompetion.
1. I mark var/cache like excluded
2. check for be sure class Symfony\Bundle\FrameworkBundle\Controller\Controller exist
$funFact = $this->container->get('markdown.parser')
when i write $this->container->(autocomplete show 'get' and other) then ->get( (here no autocomplete) )
Hey Igor,
Please, double check you have installed and *enabled* Symfony plugin in PhpStorm preferences for your project: press Command + , on Mac and type "Symfony" in search box. Then choose Languages and frameworks -> PHP -> Symfony and ensure you have checked all necessary boxes, especially the "Enable plugin for this project" one.
After all, try to restart PhpStorm. Actually, it helps in most weird behaviors of PhpStorm :)
P.S. Do you use the latest PhpStorm version?
Cheers!
"Enable plugin for this project" - helps, Thanks!
Great! Easy fix :)
Is there an explanation behind why $this->container->get() is the same as $this->get()
Hey Kelvin,
"$this->get()" in a controller is just a shortcut for "$this->container->get()". Open the Symfony\Bundle\FrameworkBundle\Controller\Controller::get() and you will see it yourself ;)
Cheers!
If you are getting transform method not implement error.
Your composr download a dev version which does not have transform() method implemented.
Do the following:
1) Update composer.json under your project root directory
"knplabs/knp-markdown-bundle": "^1.5",
2) run update in your terminal
composer update knplabs/knp-markdown-bundle
Hi, i have this error:
"You have requested a non-existent service "markdown.parser". I check and in my services list markdown is not present.
How can I add it?
Thank you.
I solved, i installed from https://github.com/KnpLabs/....
I see now, i jumped the video 1 xd
Hey Xeyos,
Haha, I really wonder how you missed this installation ;)
Cheers!
Hey Dainis,
Why are you trying to inject "markdown.helper"? The "templating.helper.markdown" service looks like the correct one ;)
Cheers!
markdown.parser seems to be having an issue getting recognized as a service and autocompleting for me. I have the symfony plugin and php annotations enabled for the project and autocomplete is working for other things.
In $this->get( ), when I start typing 'markdown' it suggests 'templating.helper.markdown', but no other services will autocomplete, but it won't find markdown.parser.
If I run ./bin/console debug:container markdown I see all the services which makes it even more confusing.
./bin/console debug:container markdown
Select one of the following services to display its information:
[0] markdown.parser.min
[1] markdown.parser.light
[2] markdown.parser.medium
[3] markdown.parser.max
[4] markdown.parser.flavored
[5] markdown.parser.parser_manager
[6] templating.helper.markdown
[7] doctrine_cache.providers.my_markdown_cache
[8] markdown.parser
>
Hey todd!
When you do `$this->get('markdown.parsers');` does it throw an exception or something?
If that's not the case and you are getting the correct object, it must be something related to PhpStorm settings, which version are you using? have you tried clearing the index? (inside settings->plugins->symfony)
Yeah, no exception so Symfony is finding it when things get executed, but PHP storm still says 'Missing service'. I've cleared the Symfony plugin index, invalidated the PHP storm caches.
Using php storm 2017.2.1. It looks like others have had a similar issue, so maybe it will just start working, who knows..
Yeah, some times it gets glitched, try excluding from your project the folder `var/cache`
Yeah, did that too. I've tried pretty much everything, but PHP storm can't seem to find any custom services I define.
Soooo I had var/cache excluded from the beginning, per the recommendation in this course. However, when excluding var/cache PHP storm won't find any of my services. IF I cancel exclusion of that var/cache, now PHP Storm can find all my services and autocomplete works great...
Are you guys sure about excluding that directory? I'm fairly certain appDevDebugProjectContainer.xml is important for mapping services.
Or if you exclude var/cache maybe you need to manually map it?
In this SO thread it seems to be an important file, but I don't have a cache directory in my app folder, only in var/cache, should I? Or is this something symfony changed recently?
https://stackoverflow.com/q...
Oh, it depends on the Symfony version you are using, I don't know when exactly they did that change (moving cache directory from app to var directory) but if you are using Symfony 3.* you need to adjust your symfony's plugin settings
Oh, really? I can't find any mention about the "markdown.helper" in script code: https://github.com/knpunive... and even in the video of this chapter. Do you mean "markdown.parser"? Could you point me to the script/video where we use the "markdown.helper", please?
Cheers!
Sorry, my bad, I meant "markdown.parser", and it's working. The PHP Symphony auto suggest initially offered me only the "templating.helper.markdown" option for some reason so it confused me. Now it's working.
Problem solved, thread can be deleted.
Thank you :-)
You're welcome! I'm glad we clarify it. And don't worry about this thread, it could help someone ;)
Cheers!
when i want to add {{ funFact }} to the dd section in show.html.twig symfony throws this error: "Variable "funFact" does not exist in genus\show.html.twig at line 17"
the fetNotesAction function looks like this:
$funFact = 'Octopuses can change the color of their body in just *three-tenths* of a second!';
$notes = [
['id' => 1, 'username' => 'AquaPelham', 'avatarUri' => '/images/leanna.jpeg', 'note' => 'Octopus asked me a riddle, outsmarted me', 'date' => 'Dec. 10, 2015'],
['id' => 2, 'username' => 'AquaWeaver', 'avatarUri' => '/images/ryan.jpeg', 'note' => 'I counted 8 legs... as they wrapped around me', 'date' => 'Dec. 1, 2015'],
['id' => 3, 'username' => 'AquaPelham', 'avatarUri' => '/images/leanna.jpeg', 'note' => 'Inked!', 'date' => 'Aug. 20, 2015'],
];
$data = [
'notes' => $notes,
'funFact' => $funFact,
];
return new JsonResponse($data);
Hey Hannes,
I suppose you forget to pass funFact variable in GenusController::showAction(), which actually renders the `genus/show.html.twig` template ;)
Cheers!
yep :P that was the problem thanks :)
"Houston: no signs of life"
Start the conversation!