I'm trying to create a simple index to a table in Doctrine2 / Symfony2 using annotations and I'm getting the following error:
我正在尝试使用注释创建Doctrine2 / Symfony2中的表的简单索引,我收到以下错误:
[Semantical Error] The annotation "@Index" in class {My\Namespaces\Here} was never imported. Did you maybe forget to add a "use" statement for this annotation?
[语义错误]类{My \ Namespaces \ Here}中的注释“@Index”从未导入。您是否忘记为此注释添加“使用”语句?
I can't find in any documentation what namespace I'm supposed to "use" to add the Index functionality. Here's my annotation:
我无法在任何文档中找到我应该“使用”添加索引功能的命名空间。这是我的注释:
@ORM\Table(indexes={@Index(name="email_address_idx", columns={"email_address"})})
And here are the namespaces I'm already using:
以下是我已经使用的命名空间:
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
What namespace do I need to use to add this functionality?
我需要使用什么命名空间来添加此功能?
2 个解决方案
#1
103
Looks like you need:
看起来你需要:
@ORM\Table(indexes={@ORM\Index(name="email_address_idx", columns={"email_address"})})
#2
14
You can use the following to solve the issue:
您可以使用以下方法解决问题:
use Doctrine\ORM\Mapping\Index;
#1
103
Looks like you need:
看起来你需要:
@ORM\Table(indexes={@ORM\Index(name="email_address_idx", columns={"email_address"})})
#2
14
You can use the following to solve the issue:
您可以使用以下方法解决问题:
use Doctrine\ORM\Mapping\Index;