PHPackages                             phun/phun - 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. phun/phun

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

phun/phun
=========

Seamlessly integrate PHP execution within your JavaScript/TypeScript projects with Phun.

50TypeScriptCI passing

Since Dec 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/siguici/phun)[ Packagist](https://packagist.org/packages/phun/phun)[ RSS](/packages/phun-phun/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (1)Used By (0)

PHP 💙 Bun (Phun)
================

[](#php--bun-phun)

Phun offers a seamless PHP integration for JavaScript/TypeScript projects, powered by Bun. It's a great choice, especially if you prefer PHP over JSX/TSX.

📋 Requirements
--------------

[](#-requirements)

Ensure you have the following installed:

- [**PHP**](https://www.php.net/downloads): Required for executing PHP code.
- [**Bun**](https://bun.sh/docs/installation): Needed for efficient PHP subprocess execution.

⚡️Installation
--------------

[](#️installation)

To install Phun, execute the following command with [Bun](https://bun.sh):

```
bun add phun
```

🔧 Configuration
---------------

[](#-configuration)

Configure Phun in your project by defining the files to import in [the Bun preload file](https://bun.sh/docs/runtime/bunfig#preload):

```
import { setup } from "phun";

setup();
```

📖 Usage
-------

[](#-usage)

Phun provides multiple ways to incorporate PHP code into your JavaScript/TypeScript projects.

### Rendering PHP Code

[](#rendering-php-code)

You can render PHP code directly using the `render()` function:

```
import { render } from 'phun';

const result = await render(``, { name: 'Sigui' });

console.log(result); // Output: Hello, Sigui!
```

### Importing PHP Modules

[](#importing-php-modules)

You can import and use PHP modules in your JavaScript/TypeScript projects:

```
import my_php_module from "my/php/module.php";

console.log(my_php_module());
```

### Dynamic Using with Data

[](#dynamic-using-with-data)

You can pass data to PHP code for dynamic rendering using the `use()` function:

```
import { use } from "phun";

const my_php_module = await use(import.meta.dir + '/my/php/module.php', { name: "Sigui", username: "siguici" });

console.log(my_php_module);
```

👏 Contributions
---------------

[](#-contributions)

Contributions are welcome! You can:

- **Open Issues**: Report bugs or suggest improvements.
- **Submit Pull Requests**: Contribute bug fixes, new features, or documentation enhancements.
- **Provide Feedback**: Share your thoughts and ideas to help improve Phun.

Let's collaborate and make Phun even more awesome together!

📄 License
---------

[](#-license)

This project is licensed under the MIT License. [See the LICENSE file for more details](./LICENSE.md).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf6cb8e2f1ce94734b0c6d2600fef865c8164f11f8f2a511cc20cd37a897d9c6?d=identicon)[siguici](/maintainers/siguici)

---

Top Contributors

[![siguici](https://avatars.githubusercontent.com/u/62618356?v=4)](https://github.com/siguici "siguici (24 commits)")

---

Tags

bunphpphun

### Embed Badge

![Health badge](/badges/phun-phun/health.svg)

```
[![Health](https://phpackages.com/badges/phun-phun/health.svg)](https://phpackages.com/packages/phun-phun)
```

PHPackages © 2026

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