I am working through part4 of Symfony2, and while updating the controller and helper class code i got the following error message
Undefined method \'getLates
In case you are using PHP-FPM then this issue might persist even after all the above solutions you have tried then use sudo service php5-fpm restart
which did the trick for me.
In Symfony 3 you are probably missing the repository class in your orm.xml
file.
repository-class="Bundle\Repository\MyRepository"
<doctrine-mapping>
<entity name="Bundle\Entity\MyEntity"
table="tablename"
repository-class="Bundle\Repository\MyRepository">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
</entity>
</doctrine-mapping>
If youre using yml as config files for your entities try adding this:
Blogger\BlogBundle\Entity\Blog:
type: entity
table: Blog
repositoryClass: Blogger\BlogBundle\Repository\BlogRepository
...
and then as mentioned above:
php app/console doctrine:generate:entities Blogger
The other solution is to delete all the orm.xml files added by generated entities. If you move the folder or delete, your mapping with repository will be operationnal.
* @ORM\Entity(repositoryClass="Blogger\BlogBundle\Repository\BlogRepository")
Try putting the repository class at the same directory next to the Entity class:
* @ORM\Entity(repositoryClass="Blogger\BlogBundle\BlogRepository")
Make sure that you have modified your entity class:
// src/Blogger/BlogBundle/Entity/Blog.php
/**
* @ORM\Entity(repositoryClass="Blogger\BlogBundle\Repository\BlogRepository")
* @ORM\Table(name="blog")
* @ORM\HasLifecycleCallbacks()
*/
class Blog
{
// ..
}
the annotation @ORM\Entity(repositoryClass="Blogger\BlogBundle\Repository\BlogRepository")
is required.
And don't forget to regenerate entities:
php app/console doctrine:generate:entities Blogger
Remove annotation @ORM\Entity
. It overrides correct annotation @ORM\Entity(repositoryClass="Blogger\BlogBundle\Repository\BlogRepository")