@@ -24,67 +24,61 @@ keys: symfony,phpzlc,entity
24
24
25
25
` {entityClassName} ` _ 选填_ 未指定的话则对话式询问,询问不指定则对所有实体生效
26
26
27
- 2 . ** 通常不建议使用命令行创建实体,直接创建类文件会比较便捷**
27
+ 1 . ** 通常不建议使用命令行创建实体,直接创建类文件会比较便捷**
28
28
29
- _ 下面提供了两组模版可以用于实体的创建。_
30
- _ 使用时请将模版中user和User部分替换。并且修改表的描述。_
29
+ _ 下面提供了两组模版可以用于实体的创建。_
30
+ _ 使用时请将模版中user和User部分替换。并且修改表的描述。_
31
31
32
- ** UUID 代码模版(推荐方式)**
32
+ ** UUID 代码模版(推荐方式)**
33
33
34
- ``` php
35
- <?php
36
- namespace App\Entity;
37
-
38
- use App\Repository\UserRepository;
39
- use Doctrine\ORM\Mapping as ORM;
40
- use Symfony\Component\Validator\Constraints as Assert;
34
+ ``` php
35
+ <?php
36
+ namespace App\Entity;
41
37
42
- /**
43
- * @ORM\Entity(repositoryClass=UserRepository::class)
44
- * @ORM\Table(name="user", options={"comment":"用户表"})
45
- */
46
- class User
47
- {
48
- /**
49
- * @var string
50
- *
51
- * @ORM\Column(name="id", type="string")
52
- * @ORM\Id()
53
- * @ORM\GeneratedValue(strategy="CUSTOM")
54
- * @ORM\CustomIdGenerator(class="PHPZlc\PHPZlc\Doctrine\SortIdGenerator")
55
- */
56
- private $id;
57
- }
58
- ```
38
+ use App\Repository\UserRepository;
39
+ use Doctrine\ORM\Mapping as ORM;
40
+ use Symfony\Component\Validator\Constraints as Assert;
41
+
42
+ #[ORM\Entity(repositoryClass: UserRepository::class)]
43
+ #[ORM\Table(name: "user", options:["comment" => "用户表"])]
44
+ class User
45
+ {
46
+ #[ORM\Id]
47
+ #[ORM\Column(name: "id", type: "string")]
48
+ #[ORM\GeneratedValue(strategy: "CUSTOM")]
49
+ #[ORM\CustomIdGenerator(class: SortIdGenerator::class)]
50
+ private ?string $id = null;
51
+ }
52
+ ```
59
53
60
- _ UUID更加方便系统向分布式系统转化。_
54
+ _UUID更加方便系统向分布式系统转化。_
61
55
62
- _ PHPZlc对UUID进行了改造,其在保持唯一性的同时,增加了如自增ID一样的排序性,缺点在于最终生成的ID较长,(如果有更好的算法,希望与我们联系)。_
56
+ _PHPZlc对UUID进行了改造,其在保持唯一性的同时,增加了如自增ID一样的排序性,缺点在于最终生成的ID较长,(如果有更好的算法,希望与我们联系)。_
63
57
64
- ** 自增ID代码模版**
58
+ **自增ID代码模版**
65
59
66
- ``` php
67
- <?php
68
- namespace App\Entity;
60
+ ```php
61
+ <?php
62
+ namespace App\Entity;
69
63
70
- use App\Repository\UserRepository;
71
- use Doctrine\ORM\Mapping as ORM;
72
- use Symfony\Component\Validator\Constraints as Assert;
64
+ use App\Repository\UserRepository;
65
+ use Doctrine\ORM\Mapping as ORM;
66
+ use Symfony\Component\Validator\Constraints as Assert;
73
67
74
- /**
75
- * @ORM\Entity(repositoryClass=UserRepository::class)
76
- * @ORM\Table(name="user", options={"comment":"用户表"})
77
- */
78
- class User
79
- {
80
- /**
81
- * @ORM\Id
82
- * @ORM\GeneratedValue
83
- * @ORM\Column(type="integer")
84
- */
85
- private $id;
86
- }
87
- ```
68
+ /**
69
+ * @ORM\Entity(repositoryClass=UserRepository::class)
70
+ * @ORM\Table(name="user", options={"comment":"用户表"})
71
+ */
72
+ class User
73
+ {
74
+ /**
75
+ * @ORM\Id
76
+ * @ORM\GeneratedValue
77
+ * @ORM\Column(type="integer")
78
+ */
79
+ private $id;
80
+ }
81
+ ```
88
82
89
83
## 生成GetSet方法,生成RepositoryClass类
90
84
0 commit comments