Doctrine Support
This documentation is for the package
darsyn/ip-doctrine, which was split into a separate package in v5+ so that PHP version requirements could be updated independently. Require that as a Composer dependency to use this functionality.
This library can be used to support IP address as column types with Doctrine
DBAL versions ^2.3 || ^3.0.
Three Doctrine types are provided to match the three version classes:
- Darsyn\IP\Doctrine\IPV4Typesupports the- IPv4class.
- Darsyn\IP\Doctrine\IPV6Typesupports the- IPv6class.
- Darsyn\IP\Doctrine\MultiTypesupports the- Multiclass.
<?php
use Darsyn\IP\Doctrine\MultiType;
use Doctrine\DBAL\Types\Type;
Type::addType('ip', MultiType::class);
If you are using Symfony, then add the following to your main configuration:
Now you can happily store IP addresses in your entities like nobody's business: