Skip to content
This repository has been archived by the owner on Sep 6, 2020. It is now read-only.

App, or Library?

kherge edited this page Mar 21, 2013 · 2 revisions

Box is diverged into two separate entities: a library and an application.

The Library

The Box library is a small collection of classes that simplify the Phar building process. They handle common tasks such as reducing file size, generating stubs, and signing Phars. On its own, the library does not provide the type of simplicity offered by the Application. It will, however, provide you much greater control in how your Phars are generated.

Caveat

When generating Phars using the library, you need to be aware of the possibility that the library's own dependencies may accidentally be added to your Phars. While you may be able to manually filter out most of its dependencies, there will still be a few left in which the Composer autoloader will forcibly load.

<?php

// autoload_real.php generated by Composer

class ComposerAutoloaderInit5f0e60db7279e8ccd8b3a92e73034ffc
{
    // ...snip...

    public static function getLoader()
    {
        // ...snip...

        require $vendorDir . '/herrera-io/file-system-functions/src/lib/fs_functions.php';
        require $vendorDir . '/herrera-io/json/src/lib/json_version.php';
        require $vendorDir . '/herrera-io/phar-update/src/lib/constants.php';

        return $loader;
    }
}

To avoid the loader from generating errors about missing required files, you may do one of the following:

  1. Include the required files. The files simply include either functions or constants, which may or may not be useful to you.
  2. Add empty files in the expected locations. Since Box itself will not invade your Phars, this option is safe and recommended if possible in your Phar.

The Application

tbw

Clone this wiki locally