taybenlor / runno

Browser-based runtime for programming languages and WASI binaries.

Home Page:https://runno.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot perform autoload for composer installed vendor libraries. (PHP runtime)

rainx opened this issue · comments

Background

I am running a PHP demo with PHP runtime with composer dependencies. I found it cannot handle autoload correctly.

How to reproduce.

I can recreate this issue by the following steps. (using this demo: https://getcomposer.org/doc/01-basic-usage.md#autoloading)

  • using composer install dependencies and compress vendor directory into tar.gz file ( vendor.tar.gz)
  • using runno-run web component to bootstrap the PHP runtime with fs
    <runno-run runtime="php-cgi" editor controls fs-url="/vendor.tar.gz">
    </runno-run>
  • trying run the following code in the web editor
<?php
require __DIR__ . '/vendor/autoload.php';

$log = new Monolog\Logger('name');
$log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING));
$log->warning('Foo');

I got the following error message:

X-Powered-By: PHP/8.2.0
Content-type: text/html; charset=UTF-8

<br />
<b>Fatal error</b>:  Uncaught Error: Class &quot;Monolog\Logger&quot; not found in /program:4
Stack trace:
#0 {main}
  thrown in <b>/program</b> on line <b>4</b><br />

I tried to use the PHP scandir function to check the directory under '/vendor', and it did have the necessary files under it.

Hope someone can look into it. thanks a lot, that's really a cool project.

Hey!

Thanks for filing this. Just wanted to confirm with you that I've seen this and plan to allocate some time to investigating it.

As some background, I'm using the VMWare Labs WASI runtime (https://github.com/vmware-labs/webassembly-language-runtimes). So I'm limited by what it supports.

@taybenlor Great, thanks for your reply, and if you need more information to help investigate, just let me know.