Homec4science

Allow in-memory maps to be registered in libphutil

Authored by James Rhodes <jrhodes@redpointsoftware.com.au> on Jan 2 2015, 02:24.

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

Committed
James Rhodes <jrhodes@redpointsoftware.com.au>Jan 2 2015, 02:24
Pushed
aubortMar 17 2017, 12:03
Parents
rPHU96c7283ab9c7: Unsquelch errors when specifying bad environments to ExecFuture
Branches
Unknown
Tags
Unknown

Event Timeline

James Rhodes <jrhodes@redpointsoftware.com.au> committed rPHU10fca52d0ff6: Allow in-memory maps to be registered in libphutil (authored by James Rhodes <jrhodes@redpointsoftware.com.au>).Jan 2 2015, 02:24