Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Blueprints as a .phar file #28

Merged
merged 1 commit into from
Feb 23, 2024
Merged

Build Blueprints as a .phar file #28

merged 1 commit into from
Feb 23, 2024

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Feb 23, 2024

Uses the Box project to build the Blueprints library to a .phar library.

To build the file, run:

vendor/bin/box compile

To try the built .phar file, run:

rm -rf new-wp/* && USE_PHAR=1 php blueprint_compiling.php

Follow-up work

The built file is 1.3MB compressed, and most of that comes from external libraries. Let's identify the largest libraries, replace them with custom and tiny implementation, and see if we can reduce the size to, say, 100KB.

@adamziel adamziel merged commit e819f95 into trunk Feb 23, 2024
adamziel referenced this pull request in WordPress/wordpress-playground Feb 28, 2024
## What is this PR doing?

Supersedes #1051

Adds a PHP Blueprints demo page where the use of
[blueprints.phar](WordPress/blueprints#28) PHP
library in Playground may be further explored. The showcase is
intentionally not added to
http://localhost:5400/website-server/demos/index.html as PHP Blueprints
may become a part of Playground core soon enough.

For more context see:

* #1025
* https://github.com/WordPress/blueprints

## How does it work?

* The built Blueprints library is included with this PR via the
`blueprints.phar` file
* A number of PHP.wasm improvements have been merged to support it:
   * #1064
   * #1065
   * #1069
* This PR ships a `fetch` subprocess handler to enable streaming network
data in the Blueprints library – it uses [a special network transport
called
`fetch`](https://github.com/WordPress/blueprints/blob/efa8deef56095bd5bcb94868787e29f7b54350f3/src/WordPress/DataSource/PlaygroundFetchSource.php)
that requests network data via `proc_open()` when running in Playground.
Why subprocesses? They provide everything a custom network handler
needs: pipes, asynchronous execution, exit codes, internal PHP plumbing.

## Follow-up work

* Support a real-time progress bar

## Testing instructions

Go to http://localhost:5400/website-server/demos/php-blueprints.html and
confirm it looks like on the screenshot below:

![CleanShot 2024-02-28 at 15 46
14@2x](https://github.com/WordPress/wordpress-playground/assets/205419/47a91d99-07f3-40a5-a046-b58f8cda952e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant