Skip to content

Commit 1402436

Browse files
Neutron-ProNeutron-Pro
authored andcommitted
Add README.MD
1 parent 3f879f0 commit 1402436

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.MD

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Doctrine Enum PHP Type
2+
3+
---
4+
5+
## Read the enum php doc:
6+
7+
> https://github.com/Neutron-Pro/enum-php
8+
9+
---
10+
11+
## Installation
12+
13+
`composer require neutronstars/doctrine-enum-php-type`
14+
15+
---
16+
17+
## Doctrine Configuration
18+
19+
If you use it, you must create a Type class for your enum:
20+
21+
```php
22+
namespace App\Types;
23+
24+
class MyEnumType extends \NeutronStars\Enum\Types\EnumType {
25+
public const MY_ENUM = 'my_enum';
26+
27+
public function getName(): string
28+
{
29+
return self::MY_ENUM;
30+
}
31+
32+
public function convertToPHPValue($value,\Doctrine\DBAL\Platforms\AbstractPlatform $platform): MyEnum
33+
{
34+
return MyEnum::from($value);
35+
}
36+
}
37+
```
38+
39+
And you must add this to the `doctrine.yaml` configuration file:
40+
41+
```yml
42+
doctrine:
43+
dbal:
44+
types:
45+
my_enum:
46+
class: App\Types\MyEnumType
47+
```
48+
49+
---

0 commit comments

Comments
 (0)