PHPackages                             sminnee/pharout - 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. sminnee/pharout

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

sminnee/pharout
===============

Phar compiler for PHP CLI tools. Derived from Composer's compile script.

015PHP

Since Sep 6Pushed 11y ago1 watchersCompare

[ Source](https://github.com/sminnee/pharout)[ Packagist](https://packagist.org/packages/sminnee/pharout)[ RSS](/packages/sminnee-pharout/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

PharOut
=======

[](#pharout)

PharOut is a tool for generating Phar distributions fo PHP CLI tools. It was derived from the Compiler.php script included in Composer's source, and has been adapted to be a more general purpose tool.

Why PharOut?
------------

[](#why-pharout)

Distributing a PHP-based CLI tool as a phar archive is a great way of making it, but the mechanisms for creating executable phar files can be a little arcane if you haven't done it before. I wanted to make it easy for developers to make use of libraries such as symfony/console to produce polished CLI tools, and then distribute them to users.

How to use
----------

[](#how-to-use)

PharOut doesn't provide much direction over how you create your project, but I lay out my CLI projects in a structure something like this:

```
bin/
    mytool
src/
    MyNamespace/
        MyTool.php
vendor/
composer.json
composer.lock
LICENSE
README.md

```

PharOut is designed to work nicely with Composer, so I suggest that you use this to manage dependencies.

To set it up, first include composer as a dev dependency in your project, and create an empty file "bin/compile". This will be the command you call to generate the phar.

```
compososer require --dev sminnee/pharout
touch bin/compile
chmod +x bin/compile

```

Use the following code as a starting point for creating your bin/compile file. In short, you create a `SilverStripe\PharOut\Compiler` object, configure it, and then call writePhar() to generate the phar.

```
#!/usr/bin/env php
