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

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

Open
rainx opened this issue Feb 4, 2024 · 2 comments

Comments

@rainx
Copy link

rainx commented Feb 4, 2024

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.

@taybenlor
Copy link
Owner

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.

@rainx
Copy link
Author

rainx commented Feb 6, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants