syntaxx/phpx-starter-kit 问题修复 & 功能扩展

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

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

syntaxx/phpx-starter-kit

Composer 安装命令:

composer create-project syntaxx/phpx-starter-kit

包简介

PHPX starter kit

README 文档

README

React-like components in PHP, running in your browser via WebAssembly.

Build interactive web applications using familiar JSX syntax, component-based architecture, and React hooks—all in PHP!

Quick Start

Create a new PHPX project in seconds:

composer create-project syntaxx/phpx-starter-kit my-app
cd my-app
composer wasm
composer serve

Open http://localhost:9999 and start building! 🚀

Your First Component

Create interactive components with JSX syntax and React hooks:

<?php

namespace Syntaxx\PHPX\Demo;

use Syntaxx\PHPX\Framework\Component;
use Syntaxx\PHPX\Framework\Runtime;
use Syntaxx\PHPX\Framework\Document;
use function Syntaxx\PHPX\Framework\useState;

function MyApp() {
    return (
        <div>
            <h1>Click to increment</h1>
            <MyButton />
        </div>
    );
}

function MyButton() {
    [$count, $setCount] = useState(0);

    $handleClick = function() use ($count, $setCount) {
        $setCount($count + 1);
    };

    return (
        <button onClick={$handleClick}>
            Count: {$count}
        </button>
    );
}

// Render to DOM
$root = Runtime::createRoot(Document::document()->getElementById('root'));
$root->render(
    Component::create("StrictMode", [], [
        Component::create("MyApp", [], [])
    ])
);

That's it! You now have a fully interactive counter running PHP in your browser.

What You Get

JSX Syntax - Write <div> just like React ✅ React Hooks - useState, state management ✅ Component Architecture - Composable, reusable components ✅ Event Handling - onClick, onChange, and more ✅ Zero JavaScript - Everything is PHP (compiled to WebAssembly) ✅ Fast Builds - Vendor caching, watch mode, live reload ready

Development Workflow

# Terminal 1: Auto-rebuild on changes
composer wasm:watch

# Terminal 2: Development server
composer serve

Edit your .phpx files in src/, save, and refresh your browser. Changes appear instantly!

Project Structure

my-app/
├── src/               # Your PHPX components (.phpx files)
│   └── App.phpx       # Main application component
├── public/            # Web root
│   ├── index.html     # HTML entry point
│   ├── css/           # Stylesheets
│   └── build/         # Compiled WebAssembly files (auto-generated)
├── bootstrap.php      # Application entry point
└── composer.json      # Dependencies and build scripts

Available Commands

Command Description
composer wasm Build for production
composer wasm:watch Auto-rebuild on file changes
composer serve Start development server (auto-detects port from 9999)
composer wasm:dev Development build with source maps

How It Works

  1. Write Components - Create .phpx files with JSX syntax
  2. Compile - PHPX compiler transforms JSX → PHP
  3. Pack - WebAssembly packer bundles your app
  4. Run - PHP WebAssembly runtime executes in browser
  5. Interact - VRZNO bridge connects PHP ↔ JavaScript/DOM

Result: Your PHP code runs entirely in the browser, no server required!

Learn More

  • Full Documentation: docs.phpx.dev (coming soon)
  • Examples: Check the src/ directory for more component examples
  • Framework Docs: See vendor/syntaxx/phpx-framework/README.md
  • Build System: See vendor/syntaxx/phpx-build-tools/README.md

Requirements

  • PHP 8.4+ (for local development/builds)
  • Composer (dependency management)
  • Modern Browser with WebAssembly support (Chrome, Firefox, Safari, Edge)

Features

🎯 React-like Experience

  • JSX syntax: <button onClick={$handler}>Click me</button>
  • Hooks: useState(), state management
  • Component composition and props
  • Declarative UI updates

Fast Development

  • Vendor caching (10-15s → 0.4s rebuilds)
  • Watch mode with auto-rebuild
  • Port auto-detection (no conflicts!)
  • Source maps for debugging

Troubleshooting

Build errors?

rm -rf build/ vendor/
composer install
composer wasm

Port already in use? The serve command auto-detects available ports (9999 → 9998 → 9997...).

Browser not loading? Check browser console (F12) for errors. Ensure WebAssembly is supported.

Contributing

Found a bug? Have a feature idea? We'd love your contribution!

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

License

MIT License - See LICENSE file for details.

Acknowledgments

Built with:

syntaxx/phpx-starter-kit 适用场景与选型建议

syntaxx/phpx-starter-kit 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 syntaxx/phpx-starter-kit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 syntaxx/phpx-starter-kit 我们能提供哪些服务?
定制开发 / 二次开发

基于 syntaxx/phpx-starter-kit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-02