Skip to content

Lazy load PHP extensions (like dom and libxml) #89

Closed

Description

@westonruter

I tried uploading the Web Stories plugin, but the plugin gave an error notice:

The following PHP extensions are missing: dom, libxml. Please contact your host to finish installation. The following PHP classes are missing: DOMAttr, DOMComment, DOMDocument, DOMElement, DOMNode, DOMNodeList, DOMText, DOMXPath. Please contact your host to finish installation. The following PHP functions are missing: libxml_use_internal_errors, libxml_clear_errors. Please contact your host to finish installation.

The dom and libxml extensions should be enabled, as they are almost always available on WordPress sites.

Activity

  1. westonruter commented on Dec 15, 2022

    @westonruter
    MemberAuthor

    I suppose that means the WITH_LIBXML build option should rather be yes here:

    '--build-arg',
    `WITH_LIBXML=no`,

  2. adamziel commented on Dec 16, 2022

    @adamziel
    Collaborator

    @westonruter It's been enabled by default, I disabled it to remove 1.21M from the bundle size (see #2).

    I do agree it can be useful, though! That's the problem of different use-cases – you don't need it for embeddable code snippets in a JavaScript-oriented WordPress course, but you do need it to use the Playground with certain WordPress plugins.

    An obvious solution would be hosting two PHP builds, with and without libxml, and having a configuration switch with some smart defaults. It would work as long as that's only about a single extension. For two, three, or five PHP extensions there would need to be something smarter. Perhaps pre-packaged "environments" for specific purposes? As in:

    • Bare-minimum PHP for optimal bundle size
    • All-in-one PHP with all the supported extensions
    • A few targeted middle-ground environments with opinionated sets of extensions
  3. swissspidy commented on Dec 21, 2022

    @swissspidy
    Member

    This list of recommended extensions might be helpful: https://make.wordpress.org/hosting/handbook/server-environment/#php-extensions

  4. adamziel commented on Jan 31, 2023

    @adamziel
    Collaborator

    Another idea: Emscripten supports dynamic libraries that are loaded lazily – Playground could use them to provide a lean initial bundle while also offering all the additional features.

  5. changed the title [-]Enable dom and libxml extensions by default[/-] [+]Lazy load extensions like dom and libxml[/+] on Apr 11, 2023
  6. adamziel commented on Apr 11, 2023

    @adamziel
    Collaborator

    Here’s v8.dev article about an unrelated topic with an example implementation of lazy-loading wasm libraries. They use the experimental JSPI api, but it should also work with the existing stable Asyncify api:

    https://v8.dev/blog/jspi

  7. adamziel commented on Apr 22, 2023

    @adamziel
    Collaborator
  8. changed the title [-]Lazy load extensions like dom and libxml[/-] [+]Lazy load PHP extensions (like dom and libxml)[/+] on Jun 2, 2023
  9. adamziel commented on Oct 9, 2023

    @adamziel
    Collaborator

    Actually – lazy loading may not be needed at all. Building PHP extensions to .so files and loading them using zend_extension= in PHP.ini would already do the trick. Blueprints would then support declaring a list of extensions to load and voila.

    I just explored that today and managed to build XDebug. The next challenge is actually loading it in PHP, dlopen seems to be disabled at the moment.

  10. adamziel commented on Oct 9, 2024

    @adamziel
    Collaborator

    JSPI support just got merged and lazy loading is now technically possible – as described in https://v8.dev/blog/jspi.

  11. fellyph commented on Sep 30, 2026

    @fellyph
    Collaborator

    Current build flags enable libxml by default; the issue comments discuss lazy loading and the size increase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions