Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Auto-updating autoload maps and custom failure handlers

Compare
Choose a tag to compare
@fredemmott fredemmott released this 16 Sep 20:13
6887841

Package Name

This is now hhvm/hhvm-autoload instead of facebook/hhvm-autoload on Composer/Packagist, for consistency with other 'core' packages such as the Hack Standard Library.

Auto-Updating Autoload Maps

To avoid the need to rebuild the map when changing Hack files, set the new devFailureHandler option to "Facebook\\AutoloadMap\\HHClientFallbackHandler" in your hh_autoload.json; when loading a definition from the map fails, hhvm-autoload will ask hh_client where to find them.

You will still need to manually rebuild if:

  • you are changing PHP files (but not when updating/adding/removing PHP dependencies with composer)
  • you are changing functions or constants that have the same name as one in the global namespaces
  • the environment variables CI, CONTINUOUS_INTEGRATION, or TRAVIS are set; the idea is that test environments should probably be closer to production, and this behavior shouldn't be used on production.

This handler is current opt-in, but is likely to be the default in development environments in a future release.

Custom Failure Handlers

You can extend Facebook\\AutoloadMap\\HHClientFallbackHandler to use it in CI environments, remove caching, etc, or directly extend FailureHandler to add other behavior - for example, logging, or following a convention such as PSR-0 or PSR-4.

Setting the failureHandler option will affect prod and dev, unless the devFailureOption is set.

Other Changes

  • removed the dependency on TypeAssert; this was effectively pinning the community to the same major version of TypeAssert as hhvm-autoload uses. In the future, we will be more conservative about adding additional dependencies.
  • .hh files are now supported by the PSR0 and PSR4 emulation
  • "extraFiles" and "autoloadFilesBehavior": "exec" now use relative paths unless relativeAutoloadRoot is set to false