phpacker

Distribution

There are multiple ways to distribute your binaries. While they are simply files, the most common distribution method in the PHP ecosystem is through Composer.

Composer doesn't natively support automatic binary selection based on environment. PHPacker solves this by use of a a specialized Composer plugin that handles platform-specific binary distribution automatically.

To get started, install the PHPacker Composer Installer plugin in your application. Important: it must be a regular dependency, not a dev-dependency.

composer require phpacker/composer-installer

Next, define your executable's alias in your composer.json file:

"extra": {
"phpacker-install": "my-app",
}

You don't need to define the typical bin section in your composer.json file. PHPacker automatically discovers your executables using the phpacker.json configuration file in your project.

When your CLI application is installed, the installer detects your phpacker.json file and creates a proxy to the correct executable for the user's platform and architecture, using my-app (or whatever alias you've defined) as the command name.

For Windows environments, executables are handled specially and do not use the .exe extension. Our Windows installation process includes:

  1. Automatic generation of a .bat file that references the binary
  2. Creation of a Unix-style proxy file with the same name as the binary, which supports WSL, Linux VMs, and similar environments