# PHP Transaction Lab

By Chason Arthur · Revision 118.063 · Published and updated November 3, 2026.

## Click and run locally

1. Extract this whole ZIP to a new directory.
2. Use Python 3.10 or later to run `python preview.py` from that directory.
3. Open the loopback URL printed by the preview.
4. Click Run this example. Use Reset to stop and clear the environment.
5. View the code, follow the tutorial, and compare the two implementations.
6. Stop the preview with Ctrl+C.

The included prebuilt browser application runs without installing its language toolchain. Serve it through the preview; opening the HTML file directly is not supported. The preview binds to 127.0.0.1 and serves only `site/`. Source and native tools remain outside that document root. A port can be selected with `python preview.py --port 4190`.

The browser executes actual PHP and SQLite through the open-source PHP.wasm runtime from WordPress Playground. Each run creates a new memory database. The last-item example replays a chosen stale-read order; it does not measure MySQL concurrency or InnoDB row locks.

No account, key, database connection, payment or customer record is needed. The package's simple local navigation is independent of the production site's navigation enhancement. Optional links to the full Zyel catalog and a fresh download point to zyel.io.

## Run native PHP and Laravel components

Use PHP 8.4 with PDO SQLite. The core has no Composer dependency:

```sh
php src/test.php
php src/run.php stock fixed
php src/run.php delivery broken
```

For the separate Laravel database-component exercise, install Composer and enable PHP mbstring:

```sh
cd src
composer install --no-interaction --no-scripts
php eloquent.php
```

The locked `illuminate/database` and `illuminate/events` components are 13.38.0. Their transitive versions are recorded in composer.lock. This is a small component exercise, not a full Laravel installation. It should report 5 lazy queries, 2 eager queries and equal results.

On Windows, enable PDO SQLite and mbstring for this process with PHP's `-d extension_dir=... -d extension=php_pdo_sqlite.dll -d extension=php_mbstring.dll` flags if they are not already configured. Do not edit a production php.ini for this lab.

The optional MySQL exercise is in `src/mysql/README.md`; use its disposable Compose environment. The public browser executes SQLite, not that MySQL recipe.

After editing PHP core files, run `python refresh_source.py` and restart the browser environment. The PHP worker reads the refreshed source copies. Each experiment creates a new memory database.


## Files and evidence

`FILE_MANIFEST.json` records SHA-256 hashes of the extracted files. `site/lab/order-once/source/manifest.json` identifies the source displayed in the code viewer. `TEST_MATRIX.md` separates browser, native and optional engine-specific checks. The recording script follows the same reviewed scenarios.

## License and revision labels

Original teaching and application code are MIT-licensed. See THIRD_PARTY_NOTICES.md for the separate runtime licenses and their source. Revision numbers identify editions and do not count earlier public updates. The publication date is separate from the revision label.
