(Walk) When comes to Symfony services:
Instead
$doctrine = $this->container->get('doctrine');
using
$doctrine = $this->getDoctrine();
As you can see, Symfony allows you to access most of its services directly from the $this variable. NetBeans will know which auto-complete to use.
Let's see why this works (inside the controller class)

This is possible because the controller class imports the registry class with the USE statement,
use Doctrine\Bundle\DoctrineBundle\Registry;
and then in the annotation of the method comment, it declares the type of the returned object with
If you call $ this-> container-> get ('doctrine'); immediately after that, autocompletion will be omitted, and you will have to use something below.
(Answer) Magic auto-complete is not working yet. Use Php Storm (it does what you request). For those who want to stick with NetBeans, you need to use manual annotation, as in the example below:
We can point NetBeans to the class that it should use for automatic completion.
1) In the terminal from the project directory, find the service you want to import:
php bin / console debug: container
If you know what you're looking for, use this instead:
php bin / console d: container | Doctrine grep
...
doctrine ---------------------------------------------- --- ------- Doctrine \ Bundle \ DoctrineBundle \ Registry
...
2) If this is not a service, use the get_class () PHP built-in function to get the class name of the object, which it represents a specific variable. Or use a reflection class. It depends on you.
3) Once you know the class name, declare a USE statement for better readability
use Doctrine\Bundle\DoctrineBundle\Registry;
4) Now that we know what the class name of the object instance in a particular variable is, we are ready to tell NetBeans what we know using comment annotations so that it can turn on auto-completion.
$doctrine = $this->container->get('doctrine');
AutoFill is now enabled. A type
$doctrine->|
then press Ctrl + Space . See image below:
