asko/elejs 问题修复 & 功能扩展

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

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

asko/elejs

最新稳定版本:v0.0.5

Composer 安装命令:

composer require asko/elejs

包简介

README 文档

README

A library that transforms PHP code into JavaScript code, enabling you to write your front-end in your back-end.

Note that it merely transforms PHP into JavaScript, meaning that the behavior of code changes according to the differences between the PHP and JavaScript runtimes. A lot of (most of) stuff is missing, especially when it comes to JS interop definitions. That said, a proof of concept is working, and demonstrates that it is indeed possible to transpile PHP into JavaScript.

Installation

composer require asko/elejs

Usage

use Asko\Js\Js;

$js = Js::fromFile('some-php-file.php');

Or:

use Asko\Js\Js;

$js = Js::fromString('<?php echo "hello, world";');

// $js becomes: console.log("hello, world");

If you also include other PHP files within your source PHP file / string, make sure to add the third parameter rootDir to where the root of those includes will be, so that you can then do relative path declarations. There is no support for __DIR__ or the like just yet, so only relative paths work.

JavaScript Interop

You can also call JS API's from your PHP, like so:

use Asko\Js\Jsi;

function my_func(): void {
    Jsi::alert("Alert about something");
}

Which would become the following JavaScript:

function my_func() {
    alert("Alert about something");
}

Support

To see the current status of things check out:

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-21