https://github.com/sunchaserinfo/doctrine-pgsql-ip
Doctrine type handlers for PostgreSQL's inet and cidr
https://github.com/sunchaserinfo/doctrine-pgsql-ip
cidr doctrine inet ip-address postgresql
Last synced: 5 months ago
JSON representation
Doctrine type handlers for PostgreSQL's inet and cidr
- Host: GitHub
- URL: https://github.com/sunchaserinfo/doctrine-pgsql-ip
- Owner: sunchaserinfo
- License: other
- Created: 2020-01-03T22:08:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-30T07:00:25.000Z (about 2 years ago)
- Last Synced: 2025-10-12T15:52:07.336Z (8 months ago)
- Topics: cidr, doctrine, inet, ip-address, postgresql
- Language: PHP
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# IP Address types for Doctrine
This library adds support for `cidr` and `inet` types of PostgreSQL in Doctrine using the [rlanvin/php-ip] library.
[rlanvin/php-ip]: https://github.com/rlanvin/php-ip
## Installation
composer require sunchaser/doctrine-pgsql-ip
## Usage
1. Register types in Doctrine
```php
getDatabasePlatform()->registerDoctrineTypeMapping(InetType::PG_TYPE, InetType::NAME);
$conn->getDatabasePlatform()->registerDoctrineTypeMapping(CidrType::PG_TYPE, CidrType::NAME);
```
`inet` accepts and retrieves both `\PhpIP\IP` for individual addresses
and `\PhpIP\IPBlock` for network masks.
Please check the type when retrieving the data.
`cidr` accepts and retrieves only `\PhpIP\IPBlock`.
## Upgrade
Changes in 3.0:
* Requirements were bumped to PHP 8.1 and Doctrine DBAL 4.0
Changes in 2.0:
* `leth/ip-address` was replaced with `rlanvin/php-ip`
* Requirements were bumped to PHP 8.0 and Doctrine DBAL 3.0