πŸ“¦πŸš€ Fast, zero config application bundler with PHARs.

Overview

Package version Build Scrutinizer Code Quality Slack License

Fork of the unmaintained box2 project. This project needs your help!

Upgrading from Box2? Checkout the upgrade guide!

Goal

The Box application simplifies the PHAR building process. Out of the box (no pun intended), the application can do many great things:

  • ⚑ Fast application bundling
  • πŸ”¨ PHAR isolation
  • βš™οΈ Zero configuration by default
  • πŸš” Requirements checker
  • 🚨 Friendly error logging experience
  • πŸ” Retrieve information about the PHAR extension or a PHAR file and its contents (box info or box diff)
  • πŸ”οΈ Verify the signature of an existing PHAR (box verify)
  • πŸ“ Use Git tags and short commit hashes for versioning
  • πŸ•΅οΈ ️ Get recommendations and warnings about regarding your configuration (box validate)
  • 🐳 Docker support (box docker)

Table of Contents

  1. Installation
    1. PHAR
    2. Phive
    3. Composer
    4. Homebrew
  2. Usage
  3. Configuration
    1. Base path (base-path)
    2. Main (main)
    3. Output (output)
    4. Permissions (chmod)
    5. Check requirements (check-requirements)
    6. Including files
      1. Force auto-discovery (force-autodiscovery)
      2. Files (files and files-bin)
      3. Directories (directories and directories-bin)
      4. Finder (finder and finder-bin)
      5. Blacklist (blacklist)
      6. Excluding the Composer files (exclude-composer-files)
      7. Excluding dev files (exclude-dev-files)
      8. Map (map)
    7. Stub
      1. Stub (stub)
      2. Alias (alias)
      3. Shebang (shebang)
      4. Banner (banner)
      5. Banner file (banner-file)
    8. Dumping the Composer autoloader (dump-autoload)
    9. Compactors (compactors)
      1. Annotations (annotations)
      2. PHP-Scoper (php-scoper)
    10. Compression algorithm (compression)
    11. Security
      1. Signing algorithm (algorithm)
      2. The private key (key)
      3. The private key password (key-pass)
    12. Metadata (metadata)
    13. Replaceable placeholders
      1. Replacements (replacements)
      2. Replacement sigil (replacement-sigil)
      3. Datetime placeholder (datetime)
      4. Datetime placeholder format (datetime-format)
      5. Pretty git commit placeholder (git)
      6. Git commit placeholder (git-commit)
      7. Short git commit placeholder (git-commit-short)
      8. Git tag placeholder (git-tag)
      9. Git version placeholder (git-version)
  4. Requirements checker
    1. Configuration
      1. PHP version requirements
      2. Extension configuration requirements
      3. Polyfills
    2. Integration with a custom stub
  5. Optimize your PHAR
    1. Review your files
    2. Compress your PHAR
    3. Optimize your code
  6. PHAR code isolation
    1. Why/Explanation
    2. Isolating the PHAR
    3. Debugging the scoping
  7. Docker support
  8. Symfony support
  9. Contributing
  10. Upgrade guide
  11. Backward Compatibility Promise (BCP)
  12. Credits

Usage

Creating a PHAR should be as simple as running box compile (no config required!). It will however assume some defaults that you might want to change. Box will by default be looking in order for the files box.json and box.json.dist in the current working directory. A basic configuration could be for example changing the PHAR permissions:

{
    "chmod": "0700"
}

You can then find more advanced configuration settings in the configuration documentation. For more information on which command or options is available, you can run:

box help

Contributing

The project provides a Makefile in which the most common commands have been registered such as fixing the coding style or running the test.

make

Backward Compatibility Promise (BCP)

The policy is for the major part following the same as Symfony's one. Note that the code marked as @private or @internal are excluded from the BCP.

The text displayed by the commands (e.g. compile or info) or the content of the error/exception messages are also not subject to the BCP.

Credits

Project originally created by: Kevin Herrera (@kherge) which has now been moved under the Humbug umbrella.

You might also like...
phalcon config loader for yaml

Phalcon Config Loarder for Yaml Loads all the yml in the directory of the app/config. Version PHP: 7.0.x, 7.1.x, 7.2.x Phalcon: 3.x Composer { "r

Default Nginx config for Magento

Default Nginx config for Magento DEMO: https://www.magenx.com Get cloud server: at DigitalOcean magento Magento upto 1.9.x default magento configurati

Easily manage git hooks in your composer config

composer-git-hooks Manage git hooks easily in your composer configuration. This command line tool makes it easy to implement a consistent project-wide

php-cs-fixer config for Yakamara projects

php-cs-fixer config for Yakamara projects Installation composer require --dev yakamara/php-cs-fixer-config Example .php-cs-fixer.dist.php: ?php $fi

Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files

Icinga Web 2 Fileshipper module The main purpose of this module is to extend Icinga Director using some of it's exported hooks. Based on them it offer

⚑️Lightning-fast linter for .env files. Written in Rust πŸ¦€

⚑️ Lightning-fast linter for .env files. Written in Rust πŸ¦€ Dotenv-linter can check / fix / compare .env files for problems that may cause the applica

A simple and fast pmmp js es6 promise virion

Promises A simple and fast pmmp js es6 promise virion Api usage these examples are in base injectable php these should be easily transferable. Example

βš™οΈ Web3 PHP CLI is a blazing fast blockchain server for local development.
βš™οΈ Web3 PHP CLI is a blazing fast blockchain server for local development.

Web3 PHP CLI is a blazing fast blockchain server for local development. This project is a work-in-progress. Code and documentation are currently under

Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.

Grafite Builder Grafite has archived this project and no longer supports or develops the code. We recommend using only as a source of ideas for your o

Comments
  • Document why there is no self-update command

    Document why there is no self-update command

    Historically, Humbug had a self-update package. I was not too happy with the implementation, there was security concerns too that I was not comfortable or familiar with and at that time there were a lot of other things to do. This resulted in that package being ditched.

    Meanwhile PHPUnit also removed its self-udpate command, a piece of explanation can be found here.

    I would like however to document better the why to have a well established and peered review reference to point to when seeing a self-update command in the wild. It would also be good to explain and document the why of some exceptions such as Composer or PHPBrew.

    enhancement 
    opened by theofidry 0
  • feat: rework docker generator to use mlocate and actually work

    feat: rework docker generator to use mlocate and actually work

    Fixes #706 and implements #564.

    Also reworked tests to not be so closely coupled to implementation. Instead:

    • Tests now confirm the correct base image is chosen
    • All required extensions are present in the docker file

    Validating generated Dockerfiles and attempting to build them should be done in an integration test not in a unit test.

    opened by SamMousa 2
  • Generated docker file is broken

    Generated docker file is broken

    Bug report

    | Question | Answer | ------------| --------------- | Box version | 4.1.0 | PHP version | 8.1.10 | Platform with version | Ubuntu 22.04.1

    Specifically the generated PHP code looks like this:

    $extensionInstalled = array_map("strtolower", \get_loaded_extensions(false));
    $requiredExtensions = ["curl", "curl", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "json", "dom", "dom", "dom", "dom", "dom", "dom", "dom", "dom", "dom", "dom", "dom", "pdo", "pdo", "filter", "libxml", "libxml", "libxml", "hash", "mongodb", "tokenizer", "tokenizer", "tokenizer", "phar", "xmlwriter", "xmlwriter", "xmlwriter", "xmlwriter", "zip", "xml"];
    $extensionsToInstall = array_diff($requiredExtensions, $extensionInstalled);
    if ([] !== $extensionsToInstall) {
        echo \sprintf("docker-php-ext-install %s", implode(" ", $extensionsToInstall));
    }
    echo "echo \"No extensions\"";
    
    

    Note here that the last line is not in an else clause. This means that the last extension to be installed will have echo appended to it. (And this will also attempt to install 2 extensions named No and extensions.

    opened by SamMousa 0
Releases(4.2.0)
Owner
Box Project
An application for building and managing Phars.
Box Project
AMD module bundler and preloader for Magento 2 stores.

baler baler is an AMD module bundler and preloader for Magento 2 stores. Getting Started (Early Alpha) If you're willing to test alpha software, pleas

Magento 180 Nov 23, 2022
An application for building and managing Phars.

An application for building and managing Phars.

Box Project 1.2k Nov 9, 2022
A wrapper around symplify/config-transformer used to update recipes and using easy coding standard for generating readable config files.

Symfony Recipes Yaml to PHP Converter This is a wrapper around the symplify/config-transformer used to convert Symfony core recipes which uses .yaml c

Alexander Schranz 3 Nov 24, 2022
πŸ”¨ Prefixes all PHP namespaces in a file/directory to isolate the code bundled in PHARs.

PHP-Scoper PHP-Scoper is a tool which essentially moves any body of code, including all dependencies such as vendor directories, to a new and distinct

Humbug 590 Jan 2, 2023
A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.

A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.

Matias Navarro Carter 105 Jan 4, 2023
πŸͺƒ Zero-dependency global `kirbylog()` helper for any content

Kirbylog The most simple, Kirby-esque way to log content to file. Most of the time, I just want to log some string or array to a file. That's what thi

Johann Schopplich 11 Nov 9, 2022
Tool based on deployer.org to perform zero downtime deployments of Magento 2 projects

Magento 2 Deployer Plus Reliable fully-automated deployments tool for Magento 2. Zero downtime deployments on Magento versions >= 2.2 Automating your

Juan Alonso 194 Dec 27, 2022
CrateKeyShopGUI Pocketmine-MP plugin which can be set in Config.yml file

CrateKeyShopGUI CrateKeyShopGUI Pocketmine-MP plugin which can be set in Config.yml file Depend FormAPI EconomyAPI PiggyCrate InvCrashFix Download Dow

null 4 Jan 7, 2022
Write to Laravel Config files and maintain file integrity

Laravel Config Writer Write to Laravel Config files and maintain file integrity. This library is an extension of the Config component used by Laravel.

Sam Geo 158 Dec 30, 2022
php-cs-fixer config for REDAXO

php-cs-fixer config for REDAXO Installation composer require --dev redaxo/php-cs-fixer-config Example .php-cs-fixer.dist.php: <?php $finder = (new P

REDAXO CMS c/o Yakamara Media GmbH & Co. KG 7 Aug 14, 2022