symfonyslugdoctrine-extensions

The annotation "@Gedmo Slug does not exist, or could not be auto-loaded


In the localhost all things work fine but after I have deployed th project I get this error

[Semantical Error] The annotation "@Gedmo\Mapping\Annotation\slug" in property 
AppBundle\Entity\Product::$slug does not exist, or could not be auto-loaded.

This is the class Product

use Gedmo\Mapping\Annotation as Gedmo;
abstract class Prodcut
{
/**
 * @var int
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * @var string
 *
 * @ORM\Column(name="name", type="string", length=255)
 */
 private $name;

/**
 * @var string
 * @Gedmo\slug(fields={"name"})
 * @ORM\Column(name="slug", type="string", length=255, unique=true)
 */
private $slug;

Solution

  • That's because you defined alias for the annotation:

    use Gedmo\Mapping\Annotation as Gedmo;
    

    and then used it as @Gedmo\slug(fields={"name"}) which interpolates to:

    @Gedmo\Mapping\Annotation\slug(fields={"name"})
    

    Correct name is with capital S:

    @Gedmo\Slug(fields={"name"})