PHPackages                             ophelios/php-ethereum-ens - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ophelios/php-ethereum-ens

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ophelios/php-ethereum-ens
=========================

ENS Resolver for PHP.

0.1.0(10mo ago)3401MITPHPPHP &gt;=8.4CI passing

Since Aug 26Pushed 10mo agoCompare

[ Source](https://github.com/ophelios-studio/php-ethereum-ens)[ Packagist](https://packagist.org/packages/ophelios/php-ethereum-ens)[ RSS](/packages/ophelios-php-ethereum-ens/feed)WikiDiscussions dev Synced 3w ago

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

PHP Ethereum ENS 🚀
==================

[](#php-ethereum-ens-)

[![Maintainability](https://camo.githubusercontent.com/14ed7164d27e1f612ed4fe875779b4671908fb423734c06dc9cdeb3fa2319140/68747470733a2f2f716c74792e73682f6261646765732f37343837633037302d623436612d346533392d393761652d3461626436383666323332302f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/ophelios-studio/projects/php-ethereum-ens)[![Code Coverage](https://camo.githubusercontent.com/aa2515c1c1b319b8b0454de333eea6d0b3aac45b1777cf8c70c9df42a0f17924/68747470733a2f2f716c74792e73682f6261646765732f37343837633037302d623436612d346533392d393761652d3461626436383666323332302f636f7665726167652e737667)](https://qlty.sh/gh/ophelios-studio/projects/php-ethereum-ens)

A lightweight PHP library for reading ENS (Ethereum Name Service) records using any standard JSON‑RPC provider. Read‑only by design, fast to adopt, and easy to extend.

✨ Features
----------

[](#-features)

- 🔄 Reverse lookup (address → primary ENS name)
- 🧩 Resolve text records and avatar for a name
- 👤 Simple profile hydrator for common records
- 🎛️ Tiny facade (EnsService) for convenience
- 🔒 Read‑only eth\_call usage (no private keys needed)
- ⚡ Works with any Ethereum‑compatible RPC endpoint

💿 Installation
--------------

[](#-installation)

Install with Composer:

```
composer require ophelios/php-ethereum-ens

```

🌱 Quick start
-------------

[](#-quick-start)

```
use Ens\EnsService;

$rpcUrl = getenv('ENS_PROVIDER_URL') ?: 'https://mainnet.infura.io/v3/';
$ens = new EnsService($rpcUrl);

// Reverse resolve (address -> ENS name)
$name = $ens->resolveEnsName('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'); // vitalik.eth

// Resolve a profile (common records by default)
$profile = $ens->resolveProfile('vitalik.eth');
```

### 🎯 Resolve individual records

[](#-resolve-individual-records)

```
use Ens\EnsService;

$rpcUrl = getenv('ENS_PROVIDER_URL') ?: 'https://mainnet.infura.io/v3/';
$ens = new EnsService($rpcUrl);

// Resolve single/multiple records (without profile)
$avatar  = $ens->resolveAvatar('vitalik.eth');
$url     = $ens->resolveRecord('vitalik.eth', 'url');
$records = $ens->resolveRecords('vitalik.eth', ['email', 'url']);
```

📚 API overview
--------------

[](#-api-overview)

- Ens\\EnsService

    - \_\_construct(string|Ens\\Web3ClientInterface $clientOrRpcUrl)
    - resolveEnsName(string $address): ?string
    - resolveProfile(string $ensName, array $records = Ens\\ProfileHydrator::DEFAULT\_RECORDS): Ens\\EnsProfile
    - resolveAvatar(string $ensName, bool $parentFallback = true): ?string
    - resolveRecord(string $ensName, string|array $record): ?string
    - resolveRecords(string $ensName, array $records): ?array
- Ens\\Resolver: resolve individual records for a name. Handles inherited resolvers and one‑level parent fallback for avatar.
- Ens\\ReverseLookup: reverse resolve address → name using registry, with default reverse resolver fallback.
- Ens\\ProfileHydrator: populate an EnsProfile with a set of requested records.
- Ens\\Utilities: normalize(string $name), namehash(string $name)
- Ens\\Web3ClientInterface / Ens\\Web3Client: thin wrapper around web3p/web3.php for eth\_call with retries.

⚙️ Configuration (custom client)
--------------------------------

[](#️-configuration-custom-client)

You can pass a custom client instead of a URL if you need to control retries or timeouts:

```
use Ens\Web3Client;
use Ens\Configuration;
use Ens\EnsService;

$client = new Web3Client(new Configuration(
    rpcUrl: 'https://mainnet.infura.io/v3/',
    timeoutMs: 10000,
    maxRetries: 3,
));

$ens = new EnsService($client);
```

🧰 Default records
-----------------

[](#-default-records)

ProfileHydrator::DEFAULT\_RECORDS includes:

- avatar, url, email, description
- social aliases: \["com.twitter", "twitter"\], \["com.github", "github"\]

When an array of keys is provided, the first matching key is mapped to the corresponding profile property; all keys in that group are still available in `$profile->texts`.

🧪 Testing
---------

[](#-testing)

The test suite contains both unit tests (with mocks) and an optional live integration test.

Run all tests (unit + integration):

```
vendor/bin/phpunit

```

Run unit tests only:

```
vendor/bin/phpunit --testsuite Unit

```

Integration tests require an Ethereum RPC URL with ENS access. Set an environment variable:

```
ENS_PROVIDER_URL=https://mainnet.infura.io/v3/

```

Then run:

```
vendor/bin/phpunit --testsuite Integration

```

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! If you find a bug or have an enhancement in mind:

- Open an issue to discuss it, or
- Send a pull request (PR) with a clear description and relevant tests.

To work on the project locally:

- Install dependencies: `composer install`
- Run unit tests: `vendor/bin/phpunit --testsuite Unit`
- Please do not modify integration tests in PRs unless specifically discussed.

📄 License
---------

[](#-license)

MIT License © 2025 Ophelios. See the LICENSE file for full text.

🗒️ Notes
--------

[](#️-notes)

- Read‑only on‑chain calls via eth\_call. No private keys are required.
- For internationalized domains, `normalize()` attempts to use `idn_to_ascii` when available.
- Mainnet registry and default reverse resolver addresses are embedded in the library.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance55

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

301d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/118052280?v=4)[ophelios](/maintainers/ophelios)[@Ophelios](https://github.com/Ophelios)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ophelios-php-ethereum-ens/health.svg)

```
[![Health](https://phpackages.com/badges/ophelios-php-ethereum-ens/health.svg)](https://phpackages.com/packages/ophelios-php-ethereum-ens)
```

###  Alternatives

[web3p/ethereum-tx

Ethereum transaction library in PHP.

193365.7k25](/packages/web3p-ethereum-tx)[kornrunner/ethereum-offline-raw-tx

Pure PHP Ethereum Offline Raw Transaction Signer

62200.8k22](/packages/kornrunner-ethereum-offline-raw-tx)[web3p/ethereum-util

A collection of utility functions for Ethereum written in PHP.

29451.6k26](/packages/web3p-ethereum-util)[kornrunner/ethereum-address

Pure PHP Ethereum Address Generator / Validator

42118.1k9](/packages/kornrunner-ethereum-address)[digitaldonkey/ecverify

A library integrating Ethereum with typed PHP.

14117.3k2](/packages/digitaldonkey-ecverify)[kornrunner/solidity

Pure PHP implementation of Solidity

1940.5k11](/packages/kornrunner-solidity)

PHPackages © 2026

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