Open kambo-1st opened 3 weeks ago
@kambo-1st Usually building a custom PHP version isn't necessary, unless you need to change the list of statically compiled extensions. There are a few different ways you can bring files in, however. What is your use-case?
@seanmorris Thanks for asking! My goal is to bundle a PHP CLI application (involving multiple files and using composer for autoloading) to run it within a PHP-WASM environment. I'm mainly aiming to get the CLI application running in the browser without requiring server-side PHP.
If building PHP isn’t necessary, I'd love to know more about the alternative ways you mentioned to bring files in, especially if it means avoiding the build process.
@kambo-1st You can load files into the FS via constructor params. You just need to use an array of objects with the following form:
const files = [
{
name: 'icudt72l.dat',
parent: '/preload/',
url: 'https://unpkg.com/php-wasm-intl/icudt72l.dat'
}
];
https://php-wasm.seanmorr.is/filesystem/loading-files.html
Those constructor params are also accessible from static HTML:
@seanmorris Thanks for the heads-up! I know about loading files via constructor params. Honestly, though, I’m not sure if this approach would be ideal for a PHP application that has over 10,325 files (some of them are composer depedencies). Do you think this is the only viable approach in this case?
@kambo-1st Ah, yea its somewhat annoying that we need to do custom builds to create emscripten preloaded FS, so I try to avoid that. The demo-web application actually uses the php-zip extension and a small script to set up the drupal, laravel, cakephp & lamias demos.
I could probably add some functionality to download and unzip a file right to the FS as well. Let me know if that sounds useful.
Thanks for explaining that to me, now it make a sense. I will try to use approach with zip file, but I am afraid that it will be too slow. Nevertheless I will try it and will see.
On Mon, 11 Nov 2024, 02:34 Sean Morris, @.***> wrote:
@kambo-1st https://github.com/kambo-1st Ah, yea its somewhat annoying that we need to do custom builds to create emscripten preloaded FS, so I try to avoid that. The demo-web application actually uses the php-zip extension and a small script to set up the drupal, laravel, cakephp & lamias demos.
I could probably add some functionality to download and unzip a file right to the FS as well. Let me know if that sounds useful.
— Reply to this email directly, view it on GitHub https://github.com/seanmorris/php-wasm/issues/70#issuecomment-2467063784, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRRG6BPZSZKFXWBO4VJ5ZT2AACQXAVCNFSM6AAAAABRE6B4QKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRXGA3DGNZYGQ . You are receiving this because you were mentioned.Message ID: @.***>
What I am trying to achieve: I want to bundle an existing PHP CLI application with a multiple files and run it with
php-wasm
by building my ownphp-wasm
with included files through the configuration in.php-wasm-rc
.Platform:
Steps to Reproduce:
npm install -g php-wasm-builder
php-wasm-builder image
(Command not found)php-wasm-build image
(This worked)php-wasm-build build
Result:
What I tried next:
npm install -g php-wasm-builder@alpha
php-wasm-builder image
(Works)php-wasm-builder build
Result:
Expected behavior: Successful build of a PHP application that can run with
php-wasm
.Actual behavior:
libicu
step.Extra question: I wonder if building PHP is really necessary. Would it be possible to just bundle a couple of PHP files without this extra step?