# How do I add a custom Doctrine data type to SlimPHP Framwork?

**URL:** <https://discourse.slimframework.com/t/how-do-i-add-a-custom-doctrine-data-type-to-slimphp-framwork/5935>\
**Category:** Questions\
**Created:** [July 1, 2024, 6:26am UTC](https://discourse.slimframework.com/t/how-do-i-add-a-custom-doctrine-data-type-to-slimphp-framwork/5935 "2024-07-01T06:26:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bezlepkin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/bezlepkin/32/1653_2.png) [@Bezlepkin](https://discourse.slimframework.com/u/Bezlepkin)\
**Post date:** [July 1, 2024, 6:26am UTC](https://discourse.slimframework.com/t/how-do-i-add-a-custom-doctrine-data-type-to-slimphp-framwork/5935/1 "2024-07-01T06:26:20Z")

</div>

I need to add tinyint type to Doctrine.  
Many examples for Symfony but no examples for SlimPHP…

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [July 1, 2024, 1:51pm UTC](https://discourse.slimframework.com/t/how-do-i-add-a-custom-doctrine-data-type-to-slimphp-framwork/5935/2 "2024-07-01T13:51:10Z")

</div>

What have you tried so far?

---

<div class="post-metadata">

**Author:** ![laylacollins](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/laylacollins/32/1638_2.png) [@laylacollins](https://discourse.slimframework.com/u/laylacollins)\
**Post date:** [July 10, 2024, 11:02am UTC](https://discourse.slimframework.com/t/how-do-i-add-a-custom-doctrine-data-type-to-slimphp-framwork/5935/3 "2024-07-10T11:02:12Z")

</div>

Hello,  
You can define a custom mapping type (TinyIntType) that extends Doctrine\DBAL\Types\Type, register it in your SlimPHP setup to handle conversions between PHP and database values, and use it in your entity definitions.

---

<div class="post-metadata">

**Author:** ![Bezlepkin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/bezlepkin/32/1653_2.png) [@Bezlepkin](https://discourse.slimframework.com/u/Bezlepkin)\
**Post date:** [August 12, 2024, 7:32am UTC](https://discourse.slimframework.com/t/how-do-i-add-a-custom-doctrine-data-type-to-slimphp-framwork/5935/4 "2024-08-12T07:32:33Z")

</div>

How can i register custom class of type Doctirna in SlimPHP?

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [August 12, 2024, 4:22pm UTC](https://discourse.slimframework.com/t/how-do-i-add-a-custom-doctrine-data-type-to-slimphp-framwork/5935/5 "2024-08-12T16:22:30Z")

</div>

Hopefully the documentation contains what you are asking for:

[https://www.slimframework.com/docs/v4/cookbook/database-doctrine.html](https://www.slimframework.com/docs/v4/cookbook/database-doctrine.html)

---

<div class="post-metadata">

**Author:** ![Bezlepkin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/bezlepkin/32/1653_2.png) [@Bezlepkin](https://discourse.slimframework.com/u/Bezlepkin)\
**Post date:** [September 30, 2024, 6:59am UTC](https://discourse.slimframework.com/t/how-do-i-add-a-custom-doctrine-data-type-to-slimphp-framwork/5935/6 "2024-09-30T06:59:59Z")

</div>

![2024-09-30_09-47-20](https://canada1.discourse-cdn.com/flex030/uploads/slimframework/original/2X/1/1e547c4a5405d73b34fa2dbf397ced20980d24ec.png)  
 ![2024-09-30_09-45-44](https://canada1.discourse-cdn.com/flex030/uploads/slimframework/original/2X/9/9aa1e127295be5d061201412563bc8bdc265b5d0.png)  
I did it like this, but it doesn’t work…
