HomePhabricator

Allow in-memory maps to be registered in libphutil

Description

Allow in-memory maps to be registered in libphutil

Summary:
This allows libphutil to have maps and libraries registered from an existing array. Currently when Phage runs (or any similar mechanism that bundles PHP into a single file or stream), all calls to PhutilSymbolLoader will return an empty set of classes when querying, because the appropriate maps haven't been loaded.

In my code, I'm using the following to load in the libphutil maps after concatenating all of the source files:

    // $library is the library name, $map is the map returned
    // from getLibraryMap.
    foreach ($maps as $library => $map) {
      $library_serialized = base64_encode(serialize($library));
      $map_serialized = base64_encode(serialize($map));
      $bootstrap->addText(<<<EOF

PhutilBootloader::getInstance()->registerInMemoryLibrary(
  unserialize(base64_decode("$library_serialized")),
  unserialize(base64_decode("$map_serialized")));

EOF
      );
    }

Test Plan: Tested inside Omni (the UNIX shell I'm working on) as part of it's bundling process (so that scripts can be run on systems without Omni).

Reviewers: epriestley, Blessed Reviewers

Reviewed By: epriestley, Blessed Reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T6844

Differential Revision: https://secure.phabricator.com/D11115

Details

Provenance
hach-queAuthored on
hach-quePushed on Jan 2 2015, 1:24 AM
Reviewer
Blessed Reviewers
Differential Revision
D11115: Allow in-memory maps to be registered in libphutil
Parents
rPHU96c7283ab9c7: Unsquelch errors when specifying bad environments to ExecFuture
Branches
Unknown
Tags
Unknown