Portals.PHP (portals_php v0.1.0)

Copy Markdown View Source

Run PHP workers under Portals.

This package bundles the dependency-free PHP worker SDK and loads it into the worker with PHP's auto_prepend_file setting, so a worker script can use Portals\Worker straight away — no require and no Composer package.

children = [
  {Portals.Pool,
   Portals.PHP.worker_opts(
     script: Application.app_dir(:my_app, "priv/php/worker.php"),
     name: MyApp.PHP,
     size: 4
   )}
]

See the PHP guide for a full walkthrough.

Summary

Functions

Build Portals.start_worker/1 / Portals.start_pool/1 options for a PHP worker script.

Functions

worker_opts(opts)

Build Portals.start_worker/1 / Portals.start_pool/1 options for a PHP worker script.

Options

  • :script (required) — path to the worker entry script, which calls (new Portals\Worker(...))->run().
  • :php — the CLI binary, as a name looked up on PATH or a path. Defaults to "php".
  • :php_args — interpreter flags placed before the script, e.g. ["-d", "memory_limit=512M"].
  • :prepend_sdk — load the SDK through auto_prepend_file. Defaults to true. Set it to false if your php.ini already uses auto_prepend_file, and require_once the SDK yourself from getenv('PORTALS_SDK_PATH') . '/portals.php'.
  • :args — arguments passed to the script. Portals appends the socket path after these, as the last argument.
  • :env — extra {name, value} environment entries; these win over the ones set here.

Every other option is passed through unchanged.