PHPackages                             fostam/pharizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. fostam/pharizer

ActiveLibrary[CLI &amp; Console](/categories/cli)

fostam/pharizer
===============

Create phar files / executables from a PHP project file structure

v2.0.0(11mo ago)260[1 issues](https://github.com/fostam/pharizer/issues)[1 PRs](https://github.com/fostam/pharizer/pulls)Apache-2.0PHPPHP ^8.2CI failing

Since Jul 3Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/fostam/pharizer)[ Packagist](https://packagist.org/packages/fostam/pharizer)[ RSS](/packages/fostam-pharizer/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (3)Versions (8)Used By (0)

pharizer
========

[](#pharizer)

Create *phar* files / executables from a PHP project file structure.

Features
--------

[](#features)

- Easy to integrate into build chains
- Supports multiple phar files per project
- Extended file filter capabilities

Install
-------

[](#install)

The easiest way to install *pharizer* is by using [composer](https://getcomposer.org/):

```
$> composer require fostam/pharizer

```

After installation, it can be called from the following location:

```
$> vendor/bin/pharizer

```

Configuration file
------------------

[](#configuration-file)

The configuration file specifies the PHARs that should be built and uses the [YAML](https://en.wikipedia.org/wiki/YAML) format. Usually, it resides at the top level of your project file structure. The default name is `pharizer.yaml`.

Example `pharizer.yaml`:

```
target-directory: dist
targets:
  myphar:
    source-directory: .
    stub-file: src/myphar.php
    filters:
      - include: ^(src|vendor)/
      - exclude: .*

  another.phar:
    source-directory: .
    stub-file: src/another.php
    filters:
      - include: ^(src|vendor)/
      - exclude: .*

```

Main Keys:

- `target-directory` *(optional)*: If all targets should be placed under a common directory, e.g. `dist`, it can be specified here. Defaults to the current directory (`.`).
- `targets`: A list of targets. A target name can have (but does not need) the `.phar` extension. It can contain a path, too. Examples: `dist/myphar.phar`, `myphar`).

Target Keys:

- `source-directory` *(optional)*: The base directory used for collecting files. Defaults to the current directory (`.`).
- `stub-file`: The "entry point" file that is invoked when the `phar` is executed or included. The location must be relative to the `source-directory`.
- `filters`: Filter patterns can be used to control which files are included in the PHAR and which not. See "Filters" for more details.
- `shebang` *(optional)*: The shebang line used for the stub file. Defaults to `#!/usr/bin/env php`.
- `exclude-pharizer` *(optional)*: If set to `true`, automatically excludes all pharizer files (if pharizer has been installed with composer for the current project). Defaults to `true`.

Commands
--------

[](#commands)

### Build

[](#build)

With the build command, all targets from the `pharizer.yaml` are built:

```
$> pharizer build

```

To build a single target, append the target name as defined in the `pharizer.yaml`:

```
$> pharizer build myphar.phar

```

### List Files

[](#list-files)

Similarly to the *build* command, the `list-files` command either processes all or a specific target from the configuration file. The command lists all files that match the filters for a target and can be used to test and try out the filters.

Filters
-------

[](#filters)

### Definition

[](#definition)

Filters are defined as a list of include and exclude regular expression (PCRE) patterns. By default, the regular expressions are not anchored, i.e. if you want them to be anchored to the beginning or end of a file path, you have to use `^` or `$`.

Delimiter escaping is handled internally, so it is *not* necessary to escape the slash character (`/`).

Patterns are matched against the full file path of each file under `source-directory`. The source path itself (including the slash in the beginning) is truncated.

Example: The file `/my/app/src/file.php` in the source directory `/my/app` will become `src/file.php` when applying filter patterns.

### Processing

[](#processing)

For each file in the `source-directory`, the patterns are processed in the order in which they have been given in the target filter list. The first pattern that matches determines whether the file is included or excluded. If no pattern matches, the file is included by default. If you want to change the default behaviour to exclude, simply add `exclude: ".*"` as last filter.

### Caveats

[](#caveats)

#### YAML Escaping

[](#yaml-escaping)

YAML does not allow characters like `*`, so when giving a pattern containing an asterisk, put it in single quotes. Avoid double quotes, as they don't work well with backslash escapes.

```
- exclude: '.*\.php'

```

#### Anchors

[](#anchors)

Try to anchor patterns either with `^` and `$` or `/` to avoid unintended matching.

Example:

```
lib/file.php
lib/file2.php
other/glibc.c

```

The pattern `include: src` would not only match the files in the `src` directory, but also the "src" part of `glibc.c`. This can be avoided by anchoring the pattern, e.g. `include: ^src/`.

Options
-------

[](#options)

### Configuration File

[](#configuration-file-1)

By default, `pharizer.yaml` in the current directory is used as configuration file. With the `-c` option, an alternative configuration file can be specified:

```
$> pharizer build -c ../myphar.yaml

```

### Verbosity

[](#verbosity)

For each successfully built target, *pharizer* will print the name and size of the target PHAR file. To turn this off, use the `-q` (quiet) option.

Return Codes
------------

[](#return-codes)

If no errors occurred, *pharizer* exits with a return code of 0, otherwise with a return code &gt; 0.

###  Health Score

41

↓

FairBetter than 89% of packages

Maintenance57

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~432 days

Recently: every ~541 days

Total

6

Last Release

343d ago

Major Versions

v1.1.0 → v2.0.02025-06-05

PHP version history (2 changes)v1.0.0PHP &gt;=7.2

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c32c6b8631d5c8b6e67cd67499be6106fe0298715cf74a38554e6608e140492?d=identicon)[fostam](/maintainers/fostam)

---

Top Contributors

[![Stammido](https://avatars.githubusercontent.com/u/123233799?v=4)](https://github.com/Stammido "Stammido (41 commits)")

---

Tags

consolephararchiveexecutablebinaryscript

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fostam-pharizer/health.svg)

```
[![Health](https://phpackages.com/badges/fostam-pharizer/health.svg)](https://phpackages.com/packages/fostam-pharizer)
```

###  Alternatives

[psy/psysh

An interactive shell for modern PHP.

9.8k545.6M719](/packages/psy-psysh)[drupal/console-core

Drupal Console Core

13514.7M12](/packages/drupal-console-core)[matthiasnoback/symfony-console-form

Use Symfony forms for Console command input

368264.8k8](/packages/matthiasnoback-symfony-console-form)[laminas/laminas-cli

Command-line interface for Laminas projects

563.7M54](/packages/laminas-laminas-cli)[inhere/console

php console library, provide console argument parse, console controller/command run, color style, user interactive, information show.

3477.4k12](/packages/inhere-console)[joomlatools/console

This command-line script helps to ease the management of Joomla sites in your development environment.

11142.4k4](/packages/joomlatools-console)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
