PHPackages                             acamposm/ipv4-address-converter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. acamposm/ipv4-address-converter

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

acamposm/ipv4-address-converter
===============================

A PHP package to easily convert IP Addresses from any format to any format.

1.0.0(5y ago)5122MITPHPPHP ^8.0

Since Mar 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/angelcamposm/ipv4-address-converter)[ Packagist](https://packagist.org/packages/acamposm/ipv4-address-converter)[ Docs](https://github.com/angelcamposm/ipv4-address-converter)[ RSS](/packages/acamposm-ipv4-address-converter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

IPv4 Address Converter
======================

[](#ipv4-address-converter)

[![License](https://camo.githubusercontent.com/aca91b97223dede7452bedfc7f1f56c767a905c3dbcd50d32018bc21e8637e62/68747470733a2f2f706f7365722e707567782e6f72672f6163616d706f736d2f697076342d616464726573732d636f6e7665727465722f6c6963656e7365)](https://packagist.org/packages/acamposm/ipv4-address-converter)[![Latest Stable Version](https://camo.githubusercontent.com/fc7785d9fbc1e32a5b05d75bb5ef06bceb421238f99a06af55cabc896c49a032/68747470733a2f2f706f7365722e707567782e6f72672f6163616d706f736d2f697076342d616464726573732d636f6e7665727465722f762f737461626c65)](https://packagist.org/packages/acamposm/ipv4-address-converter)[![Latest Unstable Version](https://camo.githubusercontent.com/38f66d9ef7dc93d8467cd9b971ee6181eaa8d11176f40a187f42dde73e438686/68747470733a2f2f706f7365722e707567782e6f72672f6163616d706f736d2f697076342d616464726573732d636f6e7665727465722f762f756e737461626c65)](https://packagist.org/packages/acamposm/ipv4-address-converter)[![Build Status](https://camo.githubusercontent.com/8e884176dfa4a5c688cbe1b8ae5dca8af2e0b4a9a9c80d0779652ac3c461b5f0/68747470733a2f2f7472617669732d63692e636f6d2f616e67656c63616d706f736d2f697076342d616464726573732d636f6e7665727465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/angelcamposm/ipv4-address-converter)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1895eb6704d2bec4acb00bf5bcc7b78746ccf607b0507cfeda8a0001f62f7c41/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616e67656c63616d706f736d2f697076342d616464726573732d636f6e7665727465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/angelcamposm/ipv4-address-converter/?branch=master)[![StyleCI](https://camo.githubusercontent.com/b877a997906ec363df5f1a057aea79125df1cd35b736cc94a891803c7b387439/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3334333138363633322f736869656c643f7374796c653d666c6174266272616e63683d6d6173746572)](https://github.styleci.io/repos/343186632)[![Total Downloads](https://camo.githubusercontent.com/3b116376395265458ea4a3fb24fae6bb4349a7bf108ef77df8c64948686648c3/68747470733a2f2f706f7365722e707567782e6f72672f6163616d706f736d2f697076342d616464726573732d636f6e7665727465722f646f776e6c6f616473)](https://packagist.org/packages/acamposm/ipv4-address-converter)

This PHP package allows you to perform IPv4 Address conversion within Laravel applications.

- [Features](#features)
    - [Conversions](#conversions)
- [Installation](#installation)
- [Usage](#usage)
    - [Input methods](#input-methods)
    - [Output methods](#output-methods)
    - [Modifiers](#modifiers)
- [Sample outputs](#sample-outputs)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Standards](#standards)
- [Credits](#credits)
- [License](#license)

Features
--------

[](#features)

The package accepts an IP address as an input and converts it to a specified IP address format.
The input and output can be one of these formats: binary string, dotted decimal, hexadecimal string, or long integer

### Conversions

[](#conversions)

Converts from:

- Binary
- Decimal
- Hexadecimal
- Long

Converts to:

- Binary
- Decimal
- Hexadecimal
- Long

Installation
------------

[](#installation)

You can install the package via [composer](https://getcomposer.org/) and then publish the assets:

Add the library to your composer.json file:

```
{
  "require": {
    "acamposm/ipv4-address-converter": "^1.0"
  }
}
```

Or use composer to install the library:

```
composer require acamposm/ipv4-address-converter
```

***Note:*** We try to follow [SemVer v2.0.0](https://semver.org/).

Usage
-----

[](#usage)

### Input Methods

[](#input-methods)

These are the valid input methods for the conversion of the IP Addresses.

#### fromBinary

[](#frombinary)

Set the input for the IP Address conversion as a binary string.

accepts`string` $addressreturnsIPv4AddressConverter#### fromDecimal

[](#fromdecimal)

Set the input for the IP Address conversion as a doted decimal string.

accepts`string` $addressreturnsIPv4AddressConverter#### fromHexadecimal

[](#fromhexadecimal)

Set the input for the IP Address conversion as a hexadecimal string.

accepts`string` $addressreturnsIPv4AddressConverter#### fromLong

[](#fromlong)

Set the input for the IP Address conversion as a long integer.

accepts`string` $addressreturnsIPv4AddressConverter### Output Methods

[](#output-methods)

These methods are valid output methods for the conversion of the IP address specified in the previous input methods.

#### toBinary

[](#tobinary)

Set binary string as desired output format.

#### toDecimal

[](#todecimal)

Set dotted decimal as desired output format.

#### toHexadecimal

[](#tohexadecimal)

Set hexadecimal string as desired output format.

#### toLong

[](#tolong)

Set long integer as desired output format.

### Modifiers

[](#modifiers)

With these modifiers we can control the output of the conversion operation.

#### withDotNotation

[](#withdotnotation)

This modifier will apply dot notation to the output of the conversion, only available to binary strings and hexadecimal strings.

Sample outputs
--------------

[](#sample-outputs)

### From Decimal to Long Integer

[](#from-decimal-to-long-integer)

This example shows how to convert a dotted-decimal IP address to a long integer IP address.

```
use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toLong()
  ->get();

var_dump($converter);
```

The output of the conversion is a integer.

```
int(3232238334)

```

### From Decimal to Binary String

[](#from-decimal-to-binary-string)

This example shows how to convert a dotted decimal IP address to binary string IP address.

```
use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toBinary()
  ->get();

var_dump($converter);
```

The output is a binary string IP Address.

```
string(32) "11000000101010000000101011111110"

```

### From Decimal to Binary String with Dot Notation

[](#from-decimal-to-binary-string-with-dot-notation)

This example shows how to convert a dotted-decimal IP address to binary string IP address with dot notation.

```
use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toBinary()
  ->withDotNotation()
  ->get();

var_dump($converter);
```

The output is a binary string IP Address with dot notation.

```
string(35) "11000000.10101000.00001010.11111110"

```

### From Decimal to Hexadecimal

[](#from-decimal-to-hexadecimal)

This example shows how to convert a dotted-decimal IP address to a hexadecimal string IP address.

```
use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toHexadecimal()
  ->get();

var_dump($converter);
```

The output of the conversion is a hexadecimal string IP address.

```
string(8) "C0A80AFE"

```

### From Decimal to Hexadecimal with Dot Notation

[](#from-decimal-to-hexadecimal-with-dot-notation)

This example shows how to convert a dotted-decimal IP address to a hexadecimal string IP address with dot notation.

```
use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->toHexadecimal()
  ->withDotNotation()
  ->get();

var_dump($converter);
```

The output of the conversion is a hexadecimal string IP address with dot notation.

```
string(11) "C0.A8.0A.FE"

```

### Output All

[](#output-all)

There's an all method, that converts an input address to all formats.
The input address for the conversion can be a binary, decimal, hexadecimal or long address.

```
use Acamposm\IPv4AddressConverter\IPv4AddressConverter;

$converter = IPv4AddressConverter::convert()
  ->fromDecimal('192.168.10.254')
  ->withDotNotation()
  ->all();

var_dump($converter);
```

The output is an object with the address converted to all formats.

```
object(stdClass)#638 (4) {
  ["binary"] =>
  string(35) "11000000.10101000.00001010.11111110"
  ["decimal"] =>
  string(14) "192.168.10.254"
  ["hexadecimal"] =>
  string(11) "C0.A8.0A.FE"
  ["long"] =>
  int(3232238334)
}

```

Testing
-------

[](#testing)

To run the tests you only need to run this command:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](https://github.com/angelcamposm/ipv4-address-converter/CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Thank you for considering contributing to the improvement of the package. Please see [CONTRIBUTING.md](https://github.com/angelcamposm/ipv4-address-converter/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover any security related issues, please send an e-mail to Angel Campos via  instead of using the issue tracker. All security vulnerabilities will be promptly addressed.

Standards
---------

[](#standards)

The php package IPv4 Address Converter, comply with the next standards:

- [PSR-1 - Basic Coding Standard](http://www.php-fig.org/psr/psr-1/)
- [PSR-4 - Autoloading Standard](http://www.php-fig.org/psr/psr-4/)
- [PSR-12 - Extended Coding Style Guide](https://www.php-fig.org/psr/psr-12/)

Credits
-------

[](#credits)

Angel Campos

License
-------

[](#license)

The package IPv4 Address Converter is an open-source package and is licensed under The MIT License (MIT). Please see [License File](https://github.com/angelcamposm/ipv4-address-converter/LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1899d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/abe2ce7c293312ef08e979cc3254362328d7b5a1a73c24656afd6077f3b0f2ad?d=identicon)[angel.campos.m](/maintainers/angel.campos.m)

---

Top Contributors

[![angelcamposm](https://avatars.githubusercontent.com/u/63554840?v=4)](https://github.com/angelcamposm "angelcamposm (90 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

conversionipv4ipv4-address-converternetworkingphpjsonlaraveladdresspackagedecimalIPbinarynetworklonghexadecimalcoverter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/acamposm-ipv4-address-converter/health.svg)

```
[![Health](https://phpackages.com/badges/acamposm-ipv4-address-converter/health.svg)](https://phpackages.com/packages/acamposm-ipv4-address-converter)
```

###  Alternatives

[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[ernysans/laraworld

Countries, Languages and Time Zones Package for Laravel 5.\*

1755.7k](/packages/ernysans-laraworld)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
