如果要添加多个唯一组合索引的话 use Doctrine\ORM\Mapping\UniqueConstraint 取多个别名应该可以
namespace App\Entity;
use App\Repository\AccountRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
#[ORM\Entity(repositoryClass: AccountRepository::class)]
#[UniqueConstraint(name:"account_ux", fields:["type", "value"])] // 这一行定义一个唯一索引实例的初始化参数
#[ORM\Table(uniqueConstraints: [UniqueConstraint::class])] // 这一行定义table需要添加的唯一索引
class Account
{
const TYPE_ACCOUNT = 0;
const TYPE_EMAIL = 1;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'smallint')]
private $type;
#[ORM\Column(type: 'string', length: 255)]
private $value;
#[ORM\Column(type: 'string', length: 13, unique: true)]
private $userId;
#[ORM\Column(type: 'boolean')]
private $enabled;
#[ORM\Column(type: 'integer')]
private $createTime;
#[ORM\Column(type: 'string', length: 255)]
private $createUser;
#[ORM\Column(type: 'integer')]
private $updateTime;
#[ORM\Column(type: 'string', length: 255)]
private $updateUser;
#[ORM\Column(type: 'string', length: 255)]
private $updateIp;
....