Hi @mehany,
I also have the same problem.
Do you found the solution?
I use the pack https://github.com/phaza/laravel-postgis for work with PostGis.
I appreciate for your opinion, please, share your experience with us.
Best regards.
Marcio
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I would like to add data types such as postgres geometry when using Doctrine\DBAL\Platforms\PostgreSqlPlatform to generate migrations of an existing database. I am not sure where to place the mapping of data types! Hope someone here can help!
I currently get the following error:
[Doctrine\DBAL\DBALException]
Unknown database type geometry requested, Doctrine\DBAL\Platforms\PostgreSqlPlatform may not support it.
Not sure yet how to follow the docs for custom-mapping-types within Laravel!
@marciocar great work putting this together here, I selected your answer as the correct answer because there is a pull request to solve this on DBAL package which should actually contain Geometry data type mapping.
P.S
Pull request was not accepted because:
this type isn't portable across different vendors and thus cannot be added to the core.
So as of now, the type should be written some where then registered like this
<?php
// in bootstrapping code
// ...
use Doctrine\DBAL\Types\Type;
// ...
// Register my type
Type::addType('mytype', 'My\Project\Types\MyType');
To convert the underlying database type of your new “mytype” directly into an instance of MyType when performing schema operations, the type has to be registered with the database platform as well - I will look into this and refer to https://laracasts.com/discuss/channels/laravel/adding-custom-dbal-to-laravel-5 answer to his own question and update this thread :
<?php
$conn = $em->getConnection();
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('db_mytype', 'mytype');
Please or to participate in this conversation.