acelaya / doctrine-enum-type

A custom Doctrine type that maps column values to enum objects using myclabs/php-enum
MIT License
132 stars 15 forks source link

No Symfony integraion guide #21

Closed errogaht closed 6 years ago

errogaht commented 6 years ago

Hi, but I cant integrate with Symfony. always get In DBALException.php line 283: Unknown column type "" requested. PhpEnumType::registerEnumType added to boot() method of kernel of Symfony 4.1

errogaht commented 6 years ago

for fix it i done with this:

$enumName = basename($enumFile, '.php');
$str = "App\Enum\\$enumName";
PhpEnumType::registerEnumType(str_replace('\\', '\\\\', $str), $str);
PhpEnumType::registerEnumType($str);

so doctrine have double:

  ["App\\Enum\\DepartmentType"]=>
  string(33) "Acelaya\Doctrine\Type\PhpEnumType"
  ["App\Enum\DepartmentType"]=>
  string(33) "Acelaya\Doctrine\Type\PhpEnumType"

if i remove any of this then doctrine:schema:update --force fails

acelaya commented 6 years ago

This library is framework-agnostic and should work in any case.

Could you provide some tests reproducing the issue?

danaki commented 6 years ago

How do I integrate your library to my Symfony4 project. Do I need a separate bundle to achieve that?

acelaya commented 6 years ago

You can create a specific bundle if you want, but it's enough to add the boilerplate code to any existing bundle (like the App bundle)

danaki commented 6 years ago

Here's what I mean https://github.com/danaki/doctrine-enum-type-bundle Not really tested.

acelaya commented 6 years ago

Cool. Nice job :)

acelaya commented 6 years ago

I'm closing this since it doesn't seem there's any problem with symfony