Maintainers

Package info

gitlab.com/php-standard-library/release-packages/sdk-phar

Issues

Type:standard-library-sdk

pkg:composer/standard-library/sdk-phar

Transparency log

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

1.0.32 2026-08-06 20:04 UTC

This package is not auto-updated.

Last update: 2026-08-12 09:01:43 UTC


README

Compiles a console application into a single, directly executable .phar file, using Box under the hood. Process/filesystem handling uses symfony/process and symfony/filesystem; the project-copy/composer-install pieces are shared with standard-library/sdk-application's directory build via standard-library/sdk's StandardLibrary\Sdk\Build\ namespace.

{
  "require-dev": {
    "standard-library/sdk-phar": "^1.0"
  }
}

Commands

CommandPurpose
bin/sdk app:build-pharCompile a console application into a single .phar file.

This is a bin/sdk command (see standard-library/sdk's README) — run it in Docker with --docker (e.g. bin/sdk app:build-phar --docker).

It reads config-dev.yaml under the section keyed by its own fully qualified class name (see standard-library/sdk's Console\Command base class).

config-dev.yaml

'StandardLibrary\Sdk\Phar\Console\Command\PharBuildCommand':
  entrypoint: bin/console
  output: artifacts/app.phar
  dirs:
    - src
  files:
    - bin/console
    - composer.json
    - composer.lock
  exclude:
    - vendor/bin
  compression: GZ
  • entrypoint is required: the CLI script (relative to the project root) that becomes the PHAR's main entry point (e.g. a Symfony Console bin/console), and must be listed under files (or fall under a listed dirs entry) so it actually ends up in the build.
  • output is required: the .phar file path (relative to the project root) the finished build is moved to.
  • dirs/files are optional. If both are empty, the whole project is used (via git clone of the project's own .git, i.e. exactly the committed tree). If either is set, only the listed directories/files are extracted via git archive, so uncommitted or gitignored files can never end up in the build even when only part of the project is selected.
  • exclude is an optional list of paths (relative to the build directory) removed after composer install, before compiling — e.g. dev tooling left behind under vendor/bin.
  • compression is optional: one of NONE, GZ (default), BZ2.

bin/sdk app:build-phar

  1. Copies the project into a temporary build directory (see dirs/files above).
  2. Runs composer install --no-dev --no-interaction in it.
  3. Removes each configured exclude path.
  4. Downloads (or reuses the cached) box.phar, and runs box compile against the build directory.
  5. Atomically moves the resulting .phar to output (removing any previous build there first).

Why Box isn't a Composer dependency

Box is deliberately not required in composer.json: as a real library dependency its own requirements conflict with what this monorepo's tooling already pins (Rector needs nikic/php-parser ^5, PHPUnit 13 needs sebastian/diff ^9, both older than what Box 4 allows). Box ships as a self-contained PHAR precisely so it can be used standalone instead — the same way this SDK already assumes composer itself is an ambient binary rather than a Composer dependency. app:build-phar downloads a pinned, checksum-verified box.phar release into the system temp directory on first use and reuses it from there afterwards.