PHPackages                             danielmabadeje/php-solidity - 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. danielmabadeje/php-solidity

ActiveLibrary[API Development](/categories/api)

danielmabadeje/php-solidity
===========================

Write Ethereum smart contracts in PHP — a PHP-to-Solidity transpiler

v0.1.0(3mo ago)50[1 PRs](https://github.com/DanielMabadeje/php-solidity/pulls)MITPHPPHP ^8.1

Since Apr 21Pushed 3mo agoCompare

[ Source](https://github.com/DanielMabadeje/php-solidity)[ Packagist](https://packagist.org/packages/danielmabadeje/php-solidity)[ RSS](/packages/danielmabadeje-php-solidity/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

PHP-Solidity 🔷
==============

[](#php-solidity-)

**Write Ethereum smart contracts in PHP.**

PHP-Solidity is a PHP-to-Solidity transpiler. You write smart contracts using familiar PHP 8 class syntax — with typed properties, attributes, and static method calls — and PHP-Solidity compiles them into valid Solidity source code ready to deploy on any EVM-compatible blockchain (Ethereum, Polygon, BSC, Arbitrum, etc.).

> PHP does not *run* on the blockchain. PHP-Solidity uses PHP purely as a **syntax layer**. Your contract file is read, parsed into an AST, and emitted as `.sol` — exactly like how TypeScript compiles to JavaScript.

---

Table of Contents
-----------------

[](#table-of-contents)

- [How It Works](#how-it-works)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Writing Your First Contract](#writing-your-first-contract)
- [EVM Types](#evm-types)
- [Attributes Reference](#attributes-reference)
- [EVM Globals](#evm-globals)
- [Examples](#examples)
- [CLI Reference](#cli-reference)
- [Programmatic API](#programmatic-api)
- [Validator](#validator)
- [Limitations](#limitations)
- [After Transpiling](#after-transpiling)

---

How It Works
------------

[](#how-it-works)

```
Your PHP Contract File
        │
        ▼
 ContractValidator      checks for blocked types, unsafe constructs
        │
        ▼
 ContractParser         reads PHP with nikic/php-parser → builds AST
        │
        ▼
 AST (ContractNode)     internal representation of the contract
        │
        ▼
 SolidityEmitter        walks the AST and outputs Solidity source
        │
        ▼
   MyContract.sol       valid Solidity, ready for solc / Hardhat / Foundry

```

---

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

[](#installation)

```
composer require php-solidity/php-solidity
```

**Requirements:** PHP 8.1+

---

Quick Start
-----------

[](#quick-start)

**1. Create your contract file:**

```
