Getting started
Requirements
- PHP 8.1+ — the streaming renderer needs Fibers, added in 8.1.
- PHPX — compiles the
.phpxJSX-like syntax to plain PHP. Installed automatically by Composer. - Node + pnpm — only needed to build the example's React island. The PHP side of
phpx-serverhas no JavaScript dependency.
Run the example
From the repo root:
composer install # PHP: the phpx-server library + PHPX compiler
composer example:build # JS: install + build the React island, compile .phpx
composer example:serve # http://localhost:8080
composer installpulls inphpx-serverand the PHPX compiler.composer example:buildinstalls the example'spnpmdependencies, builds the React island with Vite, and compilesexamples/todo/src/components.phpxto plain PHP.composer example:servestarts PHP's built-in server athttp://localhost:8080.
See progressive enhancement for yourself
Open http://localhost:8080, then reload the page with JavaScript
disabled in your browser's dev tools. The app still works: you can add,
toggle, and delete todos, and the list still streams in a moment after the
page shell. That's not a fallback mode — it's the same PHP rendering path
that runs when JavaScript is on. React just layers an optimistic, instant UI
on top once it loads.
That one test is the fastest way to understand what "progressive enhancement, not isomorphism" (see Introduction) means in practice.
Use it in your project
Neither attitude/phpx-server nor its dependency attitude/phpx is on Packagist yet, so both need to be declared as VCS repositories.
Composer only reads repositories from your project's root composer.json — never from a dependency's — so both entries go in yours, even though phpx-server's own composer.json already declares the phpx repository:
{
"require": {
"attitude/phpx-server": "^0.1.1"
},
"repositories": [
{ "type": "vcs", "url": "https://github.com/attitude/phpx-server" },
{ "type": "vcs", "url": "https://github.com/attitude/phpx" }
]
}
Then run composer install.
Once PHPX is published to Packagist, this collapses to composer require attitude/phpx-server.