Following this simple code:
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class TestController extends Controller
{
/**
* @param $value
* @return Response
*/
public function indexAction($value)
{
return new Response('Hello:' . $value);
}
}
Is any possibility to have code completion when I would like to add @Route in phpDoc? When I type @Route it should show code completion and automatic add "use" statement? I watched a symfony tutorial (I'm beginner) and in this video PHPStrom showed code completion and automatic added "use" statement... I installed symfony plugin and other things and code completions works.
PHPStorm uses the appDevUrlGenerator.php located in the dev cache folder to autocomplete routes. Check it to make sure symfony generates correct route names. #Settings > Other settings > Symfony plugin - Path to urlGenerator.php Check it's contents.
Click the Enable the Symfony plugin with autoconfiguration link in the notification message. In the Settings/Preferences dialog ( Ctrl+Alt+S ), navigate to PHP | Symfony and select the Enable Plugin for this Project checkbox.
PhpStorm provides coding assistance and navigation facilities for developing applications with the Symfony framework. Symfony support is provided by means of the Symfony Plugin. The source code for the plugin, as well as its issue tracker, can be found on GitHub.
Depending on how the Symfony project is structured, you may have to change some additional settings under PHP | Symfony. When working with a Symfony application that follows the structure generated by, for example, the symfony/framework-standard-edition Composer project, the default paths and settings will work fine.
As correctly stated by Patrik Karisch in the question's comments:
You need the to install the PHP Annotations Plugin to enable:
use
-statements... and other helpers for annotations in PHPStorm.
Installation:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With