PHPackages                             ophelios/php-ethereum-moralis - 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. [API Development](/categories/api)
4. /
5. ophelios/php-ethereum-moralis

ActiveLibrary[API Development](/categories/api)

ophelios/php-ethereum-moralis
=============================

Simple token price fetching from Moralis.io for PHP.

1.0.0(9mo ago)027MITPHPPHP &gt;=8.4CI passing

Since Sep 15Pushed 9mo agoCompare

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

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

PHP Ethereum Moralis
====================

[](#php-ethereum-moralis)

[![Maintainability](https://camo.githubusercontent.com/a078a56aabc442313f645dc1e56b755ecb8175a5bdbc1ae3f244f4541b9f6861/68747470733a2f2f716c74792e73682f6261646765732f37353866333461392d646431322d343866632d613964372d3137306230646231366165362f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/ophelios-studio/projects/php-ethereum-moralis)[![Code Coverage](https://camo.githubusercontent.com/08970d8e7617b85c76e244520333b2b75b99c94c8bd5b30d9112691ad5cdbedf/68747470733a2f2f716c74792e73682f6261646765732f37353866333461392d646431322d343866632d613964372d3137306230646231366165362f636f7665726167652e737667)](https://qlty.sh/gh/ophelios-studio/projects/php-ethereum-moralis)

A tiny PHP library to fetch ERC‑20 token information (including price) from Moralis.io. Simple facade, PSR‑16 caching support, and a typed result object.

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

[](#-features)

- Fetch current token information (including price) by contract address
- Optional caching via PSR‑16 (e.g., APCu, files, Redis)
- Typed result: Moralis\\MoralisToken with all common fields

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

[](#-installation)

Install with Composer:

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

```

Requirements: PHP &gt;= 8.4

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

[](#-quick-start)

```
use Moralis\MoralisService;

$apiKey  = getenv('MORALIS_API_KEY');
$service = new MoralisService($apiKey);

// Fetch an ERC‑20 price (defaults to chain "eth")
$token = $service->fetchToken('0x289ff00235d2b98b0145ff5d4435d3e92f9540a6');

echo $token->tokenName . " (" . $token->tokenSymbol . ") => $" . $token->usdPrice . "\n";
```

Specify a different chain:

```
$token = $service->fetchToken('0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', 'polygon');
```

📦 Result type: MoralisToken
---------------------------

[](#-result-type-moralistoken)

The library maps Moralis API JSON into a typed object:

- tokenName, tokenSymbol, tokenLogo, tokenDecimals
- nativePrice: object|null (value, decimals, name, symbol, address)
- usdPrice, usdPriceFormatted
- exchangeName, exchangeAddress
- tokenAddress
- priceLastChangedAtBlock, blockTimestamp
- possibleSpam, verifiedContract
- pairAddress, pairTotalLiquidityUsd
- securityScore
- usdPrice24hr, usdPrice24hrUsdChange, usdPrice24hrPercentChange
- percentChange24hr

🧰 Using a cache (PSR‑16)
------------------------

[](#-using-a-cache-psr16)

You can attach any PSR‑16 cache. For convenience, ophelios/php-apcu-cache provides an APCu implementation.

```
use Moralis\MoralisService;
use Ophelios\Cache\ApcuCache; // from ophelios/php-apcu-cache

$service = new MoralisService(getenv('MORALIS_API_KEY'));
$service->setCache(new ApcuCache());

$token = $service->fetchToken('0x289ff00235d2b98b0145ff5d4435d3e92f9540a6');
```

Default cache TTL is 300 seconds.

⚙️ Custom client/configuration
------------------------------

[](#️-custom-clientconfiguration)

If you need to control base URL or timeouts, you can pass your own MoralisClient.

```
use Moralis\Configuration;
use Moralis\MoralisClient;
use Moralis\MoralisService;

$cfg = new Configuration(
    apiKey: getenv('MORALIS_API_KEY'),
    baseUrl: 'https://deep-index.moralis.io/api/v2.2/',
    timeout: 10,
);
$client  = new MoralisClient($cfg);
$service = new MoralisService($client);
```

🧪 Testing
---------

[](#-testing)

This repo includes unit tests and an optional live integration test.

Run all tests:

```
vendor/bin/phpunit

```

Run unit tests only:

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

```

Integration test requires a Moralis API key. You can place it in an .env file:

```
MORALIS_API_KEY=your-key-here

```

Then run:

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

```

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

[](#-contributing)

- Open an issue for bugs or feature ideas
- Submit a PR with a clear description and tests when applicable

📄 License
---------

[](#-license)

MIT License © 2025 Ophelios. See LICENSE for details.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance57

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity53

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

282d 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-moralis/health.svg)

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.3M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1772.4k4](/packages/aimeos-prisma)

PHPackages © 2026

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