arokettu / ip-address-doctrine
Doctrine support for arokettu/ip-address
1.0.2
2024-10-23 21:00 UTC
Requires
- php: ^8.2
- arokettu/ip-address: ^2.0
- arokettu/is-resource: ^1.0
- doctrine/dbal: ^4.2
- psy/psysh: *
Requires (Dev)
- doctrine/orm: ^3.3
- phpunit/phpunit: ^10.5
- sandfox.dev/code-standard: ^1.2024.07.20
- squizlabs/php_codesniffer: *
- vimeo/psalm: ^5.26
This package is auto-updated.
Last update: 2024-12-11 14:40:33 UTC
README
Doctrine support for arokettu/ip-address with support for native types in MariaDB and PostgreSQL.
Installation
composer require arokettu/ip-address-doctrine
Usage
Available types:
- Any version IP Address in text and binary form
- IPv4 Address in text and binary form
- IPv6 Address in text and binary form
- Any version IP Block in text and binary form
- IPv4 Block in text and binary form
- IPv6 Block in text and binary form
- Native PostgreSQL types:
inet
,cidr
- Native MariaDB types:
inet4
,inet6
Example:
<?php use Arokettu\IP\AnyIPAddress; use Arokettu\IP\Doctrine\IPAddressType; use Arokettu\IP\Doctrine\VendorSpecific\PostgreSQL\InetType; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\Column; // first register types you need Type::addType(IPAddressType::NAME, IPAddressType::class); // native type should also be registered in the platform Type::addType(InetType::NAME, InetType::class); $db = DriverManager::getConnection(/* ... */); // when initializing DBAL $db->getDatabasePlatform()->registerDoctrineTypeMapping(InetType::NATIVE_TYPE, InetType::NAME); // apply to the object: class Model { #[Column(type: IPAddressType::NAME)] public AnyIPAddress $ip; #[Column(type: InetType::NAME)] public AnyIPAddress $native_ip; }
Documentation
Read full documentation here: https://sandfox.dev/php/ip-address-doctrine.html
Also on Read the Docs: https://arokettu-ip-address-doctrine.readthedocs.io/
Support
Please file issues on our main repo at GitLab: https://gitlab.com/sandfox/ip-address-doctrine/-/issues
Feel free to ask any questions in our room on Gitter: https://gitter.im/arokettu/community
License
The library is available as open source under the terms of the MIT License.