# `Portals.PHP`
[🔗](https://github.com/Ziinc/portals/blob/v0.1.0/packages/portals_php/lib/portals/php.ex#L1)

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](php.html) for a full walkthrough.

# `worker_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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
