phun/phun 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phun/phun

Composer 安装命令:

composer require phun/phun

包简介

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

README 文档

README

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

Ensure you have the following installed:

  • PHP: Required for executing PHP code.

  • Bun: Needed for efficient PHP subprocess execution.

⚡️Installation

To install Phun, execute the following command with Bun:

bun add phun

🔧 Configuration

Configure Phun in your project by defining the files to import in the Bun preload file:

import { setup } from "phun";

setup();

📖 Usage

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

Rendering PHP Code

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

import { render } from 'phun';

const result = await render(`<?= "Hello, $name!" ?>`, { name: 'Sigui' });

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

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

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 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

This project is licensed under the MIT License. See the LICENSE file for more details.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: TypeScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-27