-
Notifications
You must be signed in to change notification settings - Fork 80
App, or Library?
Box is diverged into two separate entities: a library and an application.
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.
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:
- Include the required files. The files simply include either functions or constants, which may or may not be useful to you.
- 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 Box application provides a command line interface to the Library. It attempts to replace any Phar specific code with a simple JSON configuration file. If you do not need the amount of control offered by the Library, using the Application may be more suitable. The Application itself can be built using itself. This wiki will also provide examples on how it can be used with other Phar applications created by other developers.