I recently started working on a Symfony2 project and I'm now evaluating PhpStorm. So far I really like it but I have an issue with the code warnings. Basically it doesn't seem to recognize a lot of the project's functions and a few of the native Symfony functions. I'm not sure where the problem is, maybe someone can help me get going.
The basics: It's a remote project that was already created and worked on for a while. Most of the classes/controllers/whathaveyou where crud generated and then adapted. I imported the project including the vendors dir, I only excluded cache, logs and web/js, web/css and web/images.
I've set up PhpStorm to work with Symfony2, I basically followed this tutorial
Edit: Ok, strange, for some reason, it suddenly does recognize the find statement, so never mind that. What doesn't work is my own declared repository methods, or the methods of relationships.
* @param string $field
* @param string $direction
* @return array
public function getCoursesSortedBy($field = null, $direction = null)
$qb = $this->getCoursesSortedByQuery($field, $direction);
$query = $qb->getQuery();
$entities = $em->getRepository('VbitsVCoursesCoreBundle:Course')->getCoursesSortedBy(
$request->query->get('sort','c.name'), /* sort field */
Here, getCoursesSortedBy gives a method not found warning. The repository is declared properly in the Course entity class, and the function works fine.
One of the problems is certain Symfony2 functions, for example, it doesn't recognize 'find' in this statement:
$entity = $em->getRepository('MyBundle:Course')->find($id);
I tried it so that the method isn't 'nested', but that doesn't make a difference:
$course = $em->getRepository('MyBundle:Course');
$entity = $course->find($id);
It also doesn't recognize any of the entity functions that are defined. Most of those where crud generated and properly commented.
This might have something to do with the first problem actually, because the entity variable is defined by a method it doesn't recognize, it makes sense it doesn't recognize the entity's methods either.
Another issue is found in the entities, first of all it says "Undefined class \User" (or any of the other entities) whenever a relationship is declared, for example:
* @var \User
* @ORM\JoinColumn(name="responsible_user_id", referencedColumnName="id")
Later on in the entity class there are errors when a relationship's method are used, for example
return $this->location->getCode() . ' ' . $this->code;
I'm probably missing something here, but I'm new to both Symfony2 and PhpStorm so if someone could point me in the right direction to fix these things, that would be great.
Message was edited by: Karin van den Berg