Overview of PHP runtime services

There are many services that the runtime provides to PHP extensions, including:

  • Error configuration and reporting.
  • Invoking functions and methods in the runtime.
  • Access to local/global/super global variables.
  • Defining read only constant values.
  • Writing output to the browser/console window.
  • Access to the environment (such as the current working directory).
  • Registering classes and creating object instances.
  • Obtaining configuration information.

All of these features have their own interfaces that are accessible from the RuntimeServices interface. The UML diagram below shows the object model and lists the interfaces involved (ErrorService, OutputService, InvocationService etc).

RuntimeServices.gif

The diagram also shows a few extra interfaces that are important to PHP extensions. At the top is Disposable, this implements the disposable design pattern and allows an extension to be invoked when its runtime is shutting down. Derived from Disposable, is the LifeCycleListener interface. This notifies the extension when an HTTP request is starting and ending. Finally, the Extension interface must be implemented by all PHP extensions. It has a single method called initExtension that allows the runtime to pass it a RuntimeServices interface when it is loaded.

Version 1.0.0.3.25591