Skip to content

If I did some significant work on this repo (touching almost every file), would you merge it? #147

@cweagans

Description

@cweagans

I would like to rework this repository into something more widely usable in the PHP community. Here are a few things that I've noticed:

  • A PHP extension is required to do anything. This is probably the single biggest thing blocking wide adoption of this library. The vast majority of PHP applications are hosted on shared hosting providers that don't allow installing/loading additional PHP extensions. Even for the ones that are hosted on e.g. a VPS or whatever, installing some random PHP extension is not a common thing.
  • Because the extension exposes the wasmer engine as a resource in PHP, it's impossible to write a pure PHP polyfill that would e.g. use FFI or similar to get the same functionality. It's not possible to create a new resource type directly in PHP and it is also not possible to pretend that an object is an instance of a particular resource type, so even if I write a class that has the same interface as your resource, I still can't pass it in as an argument to the constructor of e.g. \Wasm\Module. There are a couple of libraries that I'm aware of that rely on an extension, but have a pure PHP implementation as a fallback -- even if that's just via FFI. FFI is a relatively new thing to PHP, but I think it's still a viable path for people using PHP 7.4 or higher.
  • Because many of the classes are final, I also can't extend the class and make the changes that I need to make in order to support the above on my own.
  • Details about the wasmer engine need to be known to the developer in order to effectively use this library. I'm not sure that this is actually based on any real technical requirement though -- it should be possible to expose a limited but very straightforward interface to developers that encapsulates those details. As a very simple example, maybe something along the lines of:
// file.wasm exports add and multiply functions and a myval value
$wasm = \Wasm::load('/path/to/my/file.wasm');

echo($wasm->add(1, 2));
echo($wasm->multiple(2, 4));
echo($wasm->myval);

This would more or less be a 2.x version of this library (I'm not sure how you'd do this without a BC break). Maybe it's of interest?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions