An application for building and managing Phars.

Related tags

Build Tools box2
Overview

This project has been moved to https://github.com/box-project/box

If you are looking to upgrade, don't forget to have a look at the upgrade guide.


Box

Build Status

What is it?

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

  • Add, replace, and remove files and stubs in existing Phars.
  • Extract a whole Phar, or cherry pick which files you want.
  • Retrieve information about the Phar extension, or a Phar file.
    • List the contents of a Phar.
  • Verify the signature of an existing Phar.
  • Generate RSA (PKCS#1 encoded) private keys for OpenSSL signing.
    • Extract public keys from existing RSA private keys.
  • Use Git tags and short commit hashes for versioning.

Since the application is based on the Box library, you get its benefits as well:

  • On the fly search and replace of placeholders.
  • Compact file contents based on file type.
  • Generate custom stubs.

Forks

Because of the lack of proper maintenance on my part, I created a wiki page to list the known forks of this project. Please feel free to add to this list. You can find the wiki page here.

How do I get started?

You can use Box in one of three ways:

As a Phar (Recommended)

You may download a ready-to-use version of Box as a Phar:

$ curl -LSs https://box-project.github.io/box2/installer.php | php

The command will check your PHP settings, warn you of any issues, and the download it to the current directory. From there, you may place it anywhere that will make it easier for you to access (such as /usr/local/bin) and chmod it to 755. You can even rename it to just box to avoid having to type the .phar extension every time.

$ box --version

Whenever a new version of the application is released, you can simply run the update command to get the latest version:

$ box update

As a Global Composer Install

This is probably the best way when you have other tools like phpunit and other tools installed in this way:

$ composer global require kherge/box --prefer-source

As a Composer Dependency

You may also install Box as a dependency for your Composer managed project:

$ composer require --dev kherge/box

(or)

{
    "require-dev": {
        "kherge/box": "~2.5"
    }
}

Be aware that using this approach requires additional configuration steps to prevent Box's own dependencies from accidentally being added to your Phar, causing file size bloat. You can find more information about this issue on the wiki.

Once you have installed the application, you can run the help command to get detailed information about all of the available commands. This should be your go-to place for information about how to use Box. You may also find additional useful information on the wiki. If you happen to come across any information that could prove to be useful to others, the wiki is open for you to contribute.

$ box help

Creating a Phar

To get started, you may want to check out the example application that is ready to be built by Box. How your project is structured is entirely up to you. All that Box requires is that you have a file called box.json at the root of your project directory. You can find a complete and detailed list of configuration settings available by seeing the help information for the build command:

$ box help build

You may find example configuration files for popular projects on the wiki.

Once you have configured your project using box.json (or box.json.dist), you can simply run the build command in the directory containing box.json:

$ box build -v

The -v option enabled verbose output. This will provide you with a lot of useful information for debugging your build process. Once you are satisfied with the results, I recommend not using the verbose option. It may considerably slow down the build process.

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

GPG Signature

You can find kherge's GPG on keybase.io.

32E4 B747 57B1 D652 34FC 389F 293D 7712 4151 5FE8
Comments
  • Building fatals when building a larger project

    Building fatals when building a larger project

    When I try to build a phar for phpDocumentor I get the following error:

    ? Generating new stub...
    ? Compressing...
    PHP Fatal error:  Uncaught exception 'ErrorException' with message 'proc_open(): unable to create pipe Too many open files' in phar:///home/mvriel/Copy/Projects/OSS/phpDocumentor/phpDocumentor2/box.phar/src/vendors/symfony/console/Symfony/Component/Console/Application.php:974
    Stack trace:
    #0 [internal function]: KevinGH\Box\Application->KevinGH\Box\{closure}(2, 'proc_open(): un...', 'phar:///home/mv...', 974, Array)
    #1 phar:///home/mvriel/Copy/Projects/OSS/phpDocumentor/phpDocumentor2/box.phar/src/vendors/symfony/console/Symfony/Component/Console/Application.php(974): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
    #2 phar:///home/mvriel/Copy/Projects/OSS/phpDocumentor/phpDocumentor2/box.phar/src/vendors/symfony/console/Symfony/Component/Console/Application.php(793): Symfony\Component\Console\Application->getSttyColumns()
    #3 phar:///home/mvriel/Copy/Projects/OSS/phpDocumentor/phpDocumentor2/box.phar/src/vendors/symfony/console/Symfony/Component/Console/Application.php(754): Symfony\Component\Console\Application in phar:///home/mvriel/Copy/Projects/OSS/phpDocumentor/phpDocumentor2/box.phar/src/vendors/symfony/console/Symfony/Component/Console/Application.php on line 974
    
    Bug 
    opened by mvriel 26
  • Consider Added support to map file

    Consider Added support to map file

    Hello. I'm trying your library. It seems cool, thanks. But I have an issue.

    I use composer, with the native autoloader, but I use a mount point like that This is not my project, this is just a sample.

    My issue is that the autoloader can find class a the root of my project. But If I hack and copy the lib to the target-dir, it works.

    So it could me very nice to add a new option: a map between real path, and phar path:

    "map": {
      "src": "SensioLabs/Bundle/ConnectBundle"
    }
    
    Enhancement 
    opened by lyrixx 16
  • Error including

    Error including "index.php" even when "web" is set to false.

    I'm on the latest build of Box 2.0. I tried basically started with the box.json.dist file that ships with Box when making my own box file, which looks like this:

    {
        "alias": "craft.phar",
        "chmod": "0755",
        "directories": ["src/lib"],
        "finder": [
            {
                "name": "*.php",
                "exclude": [
                    "phpunit",
                    "phpunit-test-case",
                    "Tester",
                    "Tests",
                    "tests",
                    "yaml"
                ],
                "in": "src/vendors"
            }
        ],
        "main": "bin/craft",
        "output": "craft.phar",
        "stub": true
    }
    

    However, I am getting an error that the index.php doesn't exist when actually trying to run the generated Phar. So, I cloned down Box itself and ran box build and get the same error on a clean clone of Box:

    Warning: include(phar:///media/sf_Code/Laboratory/Box/box-2.0.0-rc.1-8-g77f3c19.phar/index.php):
    
    opened by taylorotwell 14
  • Phar file for v2.7.4 is broken [unexpected T_STRING in Process.php]

    Phar file for v2.7.4 is broken [unexpected T_STRING in Process.php]

    Box project claims to work under PHP 5.3.3

    This is not true anymore for v2.7.4 phar file, v2.7.2 phar file is working. Failing example: https://travis-ci.org/FriendsOfPHP/PHP-CS-Fixer/jobs/152603392#L963

    The reason is the way that box phar file was built - it uses too new deps, exactly Symfony v3.x components (in general it allows v2 || v3), which won't run under PHP 5.3.3. I would say that build is done on newer PHP version. It could be avoided by updating component deps before building the box phar with "platform": {"php": "5.3.3"} in composer.json file (example).

    Sadly, I cannot help more as phar file is built outside Travis (probably locally by project maintainers).

    Bug 
    opened by keradus 13
  • Extract class is always included & causes error

    Extract class is always included & causes error

    This is always included even if I do not include extract in my JSON or set it to false:

    if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
    Phar::interceptFileFuncs();
    set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
    Phar::webPhar(null, $web);
    include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
    return;
    }
    

    Also the Extract_Phar::START somehow evaluates to index.php, which is a non-existent file in the .phar. This is my repo (including the box.json): https://github.com/rugk/threema-msgapi-sdk-php/tree/536457329376dc657cb02a558c9dd8d802af2b67

    opened by rugk 11
  • Implement signed package

    Implement signed package

    Hi!

    I've been using box, and recently wrote a blog post for creating signed PHAR files using Box, as well as automating creation and distribution:

    • https://mwop.net/blog/2015-12-14-secure-phar-automation.html

    One point that has been raised by some of my readers is that I detail creating a signed PHAR, but then use an unsigned phar to create it, namely the one from box-project.

    It'd be awesome if you could sign your phar files and provide a public key for verification; essentially, it would be one more level of trust in the chain. Let me know if I can be of any assistance in this!

    Enhancement 
    opened by weierophinney 11
  • Adds release date replacement (closes #103)

    Adds release date replacement (closes #103)

    As mentioned in #103 it would be nice to specify a release date a la composer. The placeholder name is datetime but maybe releasedatecould be more meaningful.

    As of now the output is a string like 2015-10-28 10:34:23

    opened by micheleorselli 11
  • '  failed to open stream: No such file or directory ' with laravel

    ' failed to open stream: No such file or directory ' with laravel

    i want to build application with laravel and after i build it with 'box' the box.json file ::

    {
        "alias": "test.phar",
        "chmod": "0755",
        "directories": ["src/app", "src/public", "src/bootstrap"],
        "files": [
            "src/vendor/autoload.php"
        ],
        "finder": [{
            "name": "*.php",
            "exclude": ["Tests", "tests", "test-suite"],
            "in": "src/vendor"
        }],
    
        "git-version": "package_version",
        "main": "bin/index",
        "output": "bin/blog.phar",
        "stub": true
    }
    

    and run it from the command line the console print this error :

    PHP Warning:  require(/vendor/laravel/framework/src/Illuminate/Foundation/start.php): failed to open stream: No such file or directory in phar:///opt/lampp/htdocs/phars/test/bin/blog.phar/src/bootstrap/start.php on line 60
    PHP Stack trace:
    PHP   1. {main}() /opt/lampp/htdocs/phars/test/bin/blog.phar:0
    PHP   2. require() /opt/lampp/htdocs/phars/test/bin/blog.phar:10
    PHP   3. require() phar:///opt/lampp/htdocs/phars/test/bin/blog.phar/bin/index:3
    PHP   4. require_once() phar:///opt/lampp/htdocs/phars/test/bin/blog.phar/src/public/index.php:35
    PHP Fatal error:  require(): Failed opening required '/vendor/laravel/framework/src/Illuminate/Foundation/start.php' (include_path='phar:///opt/lampp/htdocs/phars/test/bin/blog.phar/src/vendor/phpseclib/phpseclib/phpseclib:.:/opt/lampp/lib/php') in phar:///opt/lampp/htdocs/phars/test/bin/blog.phar/src/bootstrap/start.php on line 60
    PHP Stack trace:
    PHP   1. {main}() /opt/lampp/htdocs/phars/test/bin/blog.phar:0
    PHP   2. require() /opt/lampp/htdocs/phars/test/bin/blog.phar:10
    PHP   3. require() phar:///opt/lampp/htdocs/phars/test/bin/blog.phar/bin/index:3
    PHP   4. require_once() phar:///opt/lampp/htdocs/phars/test/bin/blog.phar/src/public/index.php:35
    

    and my directory structure :

    .
    ├── bin
    │   ├── blog.phar      # the output
    │   ├── index            # the main file
    │   ├── index.php    ## to access the phar from the browser
    │   └── storage
    ├── box.json
    └── src
        ├── app
        ├── artisan
        ├── bootstrap
        │   ├── autoload.php
        │   ├── paths.php
        │   └── start.php
        ├── composer.json
        ├── composer.lock
        ├── CONTRIBUTING.md
        ├── phpunit.xml
        ├── public
        │   ├── favicon.ico
        │   ├── index.php         ## the main file for web app
        │   ├── packages
        │   └── robots.txt
        ├── readme.md
        ├── server.php
        └── vendor
    
    

    where is my mistake ??

    opened by ghost 11
  • Merge box.json and box.json.dist

    Merge box.json and box.json.dist

    Hi! :)

    At the moment, when running box with a box.json and a box.json.dist present, box completely ignores box.json.dist. I think it would be great if box would merge both, because that would allow to define the defaults in the .dist and to override specific local settings (private key) in the box.json without having to copy everything.

    Cheers, Bernhard

    opened by webmozart 7
  • Command: missing bootstrap loading fixed

    Command: missing bootstrap loading fixed

    There is actually silent error ATM when loading bootstrap. This should really load it.

    It's never used, only in tests, see loadBootstrap method presence

    opened by TomasVotruba 7
  • New feature: Support phar update

    New feature: Support phar update

    Hello,

    It could be very nice to be able to trigger: box update. Because when the project is quite big, the phar compilation is slow ;) We already did a things like this, so it's possible...

    Enhancement 
    opened by lyrixx 7
  • Some dependencies are abandoned

    Some dependencies are abandoned

    Some dependencies are abandoned:

    Package phine/exception is abandoned, you should avoid using it. No replacement was suggested.
    Package phine/path is abandoned, you should avoid using it. No replacement was suggested.
    Package herrera-io/version is abandoned, you should avoid using it. No replacement was suggested.
    Package herrera-io/json is abandoned, you should avoid using it. Use kherge/json instead.
    Package herrera-io/phar-update is abandoned, you should avoid using it. No replacement was suggested.
    Package herrera-io/annotations is abandoned, you should avoid using it. No replacement was suggested.
    
    opened by filips123 0
  • Docker image

    Docker image

    I have written a Docker image (from official php7 alpine3 image) to use this amazing tool:

    • https://github.com/ebuildy/docker-box
    • https://hub.docker.com/r/ebuildy/box/

    docker run -v $PWD:/app ebuildy/box:v0.0.4 build

    Tell me what do you think about!

    opened by ebuildy 3
  • Can't build without git

    Can't build without git

    Unfortunately, where I work we still use svn to version control. And I had to make a copy of the project and git init then git commit to being able to build.

    opened by paulovitorbal 3
  • Issue when including Crypt/RSA.php

    Issue when including Crypt/RSA.php

    Fatal error: Class 'phpseclib\Crypt\Common\AsymmetricKey' not found in /var/www/html/kowboykit.com/htdocs/phpseclib/Crypt/RSA.php on line 63

    Is throwing every time I use include('Crypt/RSA.php');

    opened by mtstedman 0
  • Box allows Symfony 3.x console component, but uses 2.x Dialog helper internally

    Box allows Symfony 3.x console component, but uses 2.x Dialog helper internally

    Dialog helper was deprecated from 2.5, should be replaced by Question helper. Breaks on asking for the passphrase to a private key when signing phars with openssl. Temporary workaround, when installing box as an isolated composer dev dependency, is to manually require-dev symfony/console for 2.8.

    opened by padraic 1
Releases(2.7.5)
Owner
Box Project
An application for building and managing Phars.
Box Project
Hi I'm Bob! I'm a tiny and messy build tool for PHP projects

Bob, your friendly builder Hello World Put this in a file named bob_config.php in your project's root: <?php namespace Bob\BuildConfig; task('defaul

Christoph Hochstrasser 105 Mar 4, 2022
Danger runs during your CI process, and gives teams the chance to automate common code review chores.

Danger runs during your CI process, and gives teams the chance to automate common code review chores. This project ports Danger to PHP. This project is still in the early phase. Feel free to try it out and contribute!

Shyim 55 Dec 7, 2022
GitHub Action that diffs composer.lock between current branch and default branch

github-action-composer.lock-diff GitHub Action that diffs composer.lock between current branch and default branch Options (inputs) This action support

Cees-Jan Kiewiet 13 Oct 31, 2022
Unpacking and packaging for Qualcomm splash images

Magic Splash Wand Magic Splash!! Wand Unpacking and packaging for Qualcomm splash images. How to use Download and install PHP for your system from the

Jim Wu 6 Oct 25, 2022
An application for building and managing Phars.

An application for building and managing Phars.

Box Project 1.2k Nov 9, 2022
📦🚀 Fast, zero config application bundler with PHARs.

Fork of the unmaintained box2 project. This project needs your help! Upgrading from Box2? Checkout the upgrade guide! Goal The Box application simplif

Box Project 865 Dec 26, 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 library for managing database connections, results pagination and building queries in PHP

PHP lions-software-database-manager This is a simple library for managing database connections, results pagination and building queries in PHP. Esta é

Lions Software 0 Feb 7, 2022
A Symfony application for managing and automating regular backups of MySQL databases.

DbSaver DbSaver is an application written by Bastien LOUGHIN allowing you to make automatic daily backups (and manual backups) for your MySQL database

Bastien 35 Nov 11, 2022
Registry manager for Laravel 5. An alternative for managing application configurations and settings.

Registry manager for Laravel 5. An alternative for managing application configurations and settings. Now with the magic of caching, so no more database calls to simply get site setting.

Daniel Stainback 22 Sep 28, 2020
This package should help you with creating and managing a Laravel DDD Application

This package should help you with creating and managing a Laravel DDD Application. This package is heavily inspired by "Laravel beyond CRUD" from Spatie.

J. Regner 158 Dec 25, 2022
FileGator - a free, open-source, self-hosted web application for managing files and folders.

FileGator - Powerful Multi-User File Manager FileGator is a free, open-source, self-hosted web application for managing files and folders. You can man

FileGator 1.3k Jan 3, 2023
Online web application developed in PHP using Laravel framework for managing real-time kitchen orders in a restaurant.

Online web application developed in PHP using Laravel framework for managing real-time kitchen orders in a restaurant. It allows, through a web panel, real-time communication between chefs and waiters about the status of orders.

Fernando 2 Nov 9, 2022
CRUD php application to check in and check out employees and show daily building occupation

CRUD php application to check in and check out employees and show daily building occupation. Employees are required to self check their temperature and tick a checkbox to specify whether their temperature is below 38°C else they are invited to stay home. (Implemented in php with bootstrap4 for styling and datatable jquery plugin for table formatting and additional features).

null 2 Feb 20, 2022
A course database lookup tool and schedule building web application for use at Rochester Institute of Technology.

CSH ScheduleMaker A course database lookup tool and schedule building web application for use at Rochester Institute of Technology. Built, maintained

Computer Science House 55 Nov 8, 2022
This is a Task Manager system for managing your task. You can categorize your tasks and upload music to the project And a whole host of other features

taskManager Login and register Each user can have their own task Categorize tasks by creating folders Edit and Delete Folders Search for Tasks Show nu

masoudharooni 11 May 22, 2022
Scaffold plugin for creating and managing Blocks, Block Patterns, Block Styles and Block Editor Sidebars in the WordPress Block Editor (aka Gutenberg).

WordPress Block Editor Scaffold This project is a template repo for developing WordPress Blocks, Block Patterns, Block Styles and Block Editor Sidebar

Rareview 6 Aug 2, 2022
Mofhy is a secure, fast and responsive client area for managing MyOwnFreeHost accounts and ssl certificates.

Mofhy is an open-source MyOwnFreeHost client area for managing accounts and ssl certificates. It has easy to use features much like the WHMCS Digit UI interface

Mofhy 12 Dec 15, 2022
A high-performance license server system service for creating and managing products, major versions, and software licenses for the purpose of selling installable software products.

A high-performance license server system service for creating and managing products, major versions, and software licenses for the purpose of selling installable software products. Comes with a SDK and command-line tool. Works anywhere that PHP runs.

CubicleSoft 32 Dec 5, 2022
An application for building micro-services in PHP ^8.

Restolia An application for building micro-services in PHP ^8. Install composer create-project restolia/restolia my-app Services Each service lives i

null 1 May 1, 2022