Giter VIP home page Giter VIP logo

box2's Introduction

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

box2's People

Contributors

christiaan avatar cordoval avatar empi89 avatar fabpot avatar flip111 avatar hason avatar ickbinhier avatar jojosch avatar keradus avatar kherge avatar kherrera-ebsco avatar mbrodala avatar mhor avatar ocramius avatar pborreli avatar sasezaki avatar smatyas avatar stof avatar theofidry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

box2's Issues

Add deployment command

A command for deploying an updated box.phar would be extremely useful, and simplify the update-commit-push-create-publish cycle.

Unable to install kherge/version

When trying to install dependencies for kherge/box I eventually end up trying to install kherge/version. Here the following happens:

Installing kherge/version (1.0.1)
    Downloading: connection...
Could not fetch https://api.github.com/repos/kherge/Version/zipball/f07cf83f8ce533be8f93d2893d96d674bbeb7e30, enter your GitHub credentials to access private repos
The credentials will be swapped for an OAuth token stored in /Users/kasper/.composer/config.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username: kasperg
Password:
    Downloading: connection...


  [Composer\Downloader\TransportException]
  The "https://api.github.com/repos/kherge/Version/zipball/f07cf83f8ce533be8f93d2893d96d674bbeb7e30" file could not be downloaded (H
  TTP/1.1 404 Not Found)

I guess this happens because the project has been deprecated/moved and composer cannot handle this.

If kherge/version has been deprecated for herrera-io/php-version I think some more composer files need to be updated to reflect this as well.

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

Can't install on php 5.3.10 with Suhosin-Patch

Box installer doesn't work on php 5.3.10 with Suhosin patch

As far as I understand adding suhosin.executor.include.whitelist = phar will work only for Suhosin extension. Suhosin patch seems to ignore this keyword.

After I commented out suhosin check, installed worked as expected, so it seems that white listing isn't required for patch.

Composer installer checks white list only for extension: composer/getcomposer.org@9b43609

Also similar issue can be seen here symfony/symfony#5444 (comment)

Add support for Phar::interceptFileFuncs

Add a configuration option that toggles the use of Phar::interceptFileFuncs on and off.

This option will likely only be supported by the default stub generated by Box.

Support multiple locales in app messages

The messages output by Box should support more locales than just English.

I will probably use Symfony's Translator component and bundle an English localization file for starters.

More verbose create command

The --verbose option should cause the create command to output more information than just the files that are added.

The verbose output should also include whether user given or default information is used.

An example would be: Was a user given stub file used, or was one generated by Box?

This could be useful for debugging configuration settings.

Load third-party compactors using Phar

The Box Phar should be able to load third-party compactors.

There would probably needs to be an optional configuration setting that builders can use to specific an bootstrap file that can be included by Box prior to the build process.

Consider adding an option to avoid comment stripping

At the moment, all comments are stripped by default. This introduces bugs in the compiled code if for example Doctrine annotations are removed.

I'd therefore suggest to make this an optional switch can be enabled/disabled, or not strip Doctrine annotations. The latter seems more complex though.

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):

Load only used classes

It would be great if Box somehow figured out which classes were used, and only included those in the load.

The workaround for now is using an explicit file list to list all of the files.

Error on adding the same file twice

I am just wondering how to show an error message if users add the same file twice to the phar, e.g. by specifying a directory and including files of the directory via the finder method too. Currently there is only a call to addFile (https://github.com/kherge/Box/blob/2.0/src/lib/KevinGH/Box/Command/Build.php#L668) without checking if the file is already in. The underlying library does not hold a state which files are in the phar (https://github.com/herrera-io/php-box/blob/master/src/lib/Herrera/Box/Box.php#L117) and could not check either.

Maybe it would be good to change the library to store all added files in an array and expose a method like getFiles() or isFileOnPath($path)?

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"
}

installer.php not always available.

My travis builds are failing recently, because the http://box-project.org/installer.php is sometimes not available.

Example output from curl:

$ curl --verbose http://box-project.org/installer.php
* About to connect() to box-project.org port 80 (#0)
* Trying 204.232.175.78... connected
> GET /installer.php HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: box-project.org
> Accept: */*
> 
< HTTP/1.1 302 Found
< Connection: close
< Pragma: no-cache
< cache-control: no-cache
< Location: /installer.php
<
* Closing connection #0

Would a different call to curl fix this?

Maybe using '--location' or '--retry 3'.

box.phar returns Hs?

When I try to run box.phar after installing the project using the installer the command always seems to return Hs?.

If I clone the master branch of the project, install dependencies using composer and finally run php ./bin/box I get the expected Symfony console application overview.

Is there a problem with the current box.phar or could it be something that is not configured right on my local system?

I'm using:

  • OSX 10.8.3
  • PHP 5.3.16

Use constant names instead of values

It would be far better to use the Phar::* constants instead of setting their values directly in the configuration file.

{
    "algorithm": "SHA1"
}

Would resolve to constant("Phar::$algorithm") if it exists.

Installer is failing

Hello
when I run

curl -s http://box-project.org/installer.php | php

I get the warnings below, and the resulting box.phar file doesn't do anything.

I am running Mac OSX 10.8.4
PHP 5.3.25 (cli) (built: May 29 2013 12:16:24)

Thanks
Todd

ERROR

Checking requirements...
PHP Notice: Use of undefined constant STDERR - assumed 'STDERR' in - on line 13
PHP Stack trace:
PHP 1. {main}() -:0
PHP 2. Installer::run() -:3
PHP 3. Installer::checkRequirements() -:8
PHP 4. Installer::assert() -:10
PHP 5. Installer::warn() -:9

Notice: Use of undefined constant STDERR - assumed 'STDERR' in - on line 13

Call Stack:
0.2043 775464 1. {main}() -:0
0.2043 775464 2. Installer::run() -:3
0.2043 775464 3. Installer::checkRequirements() -:8
0.2044 776360 4. Installer::assert() -:10
0.2044 776360 5. Installer::warn() -:9

PHP Warning: fwrite() expects parameter 1 to be resource, string given in - on line 13
PHP Stack trace:
PHP 1. {main}() -:0
PHP 2. Installer::run() -:3
PHP 3. Installer::checkRequirements() -:8
PHP 4. Installer::assert() -:10
PHP 5. Installer::warn() -:9
PHP 6. fwrite() -:13

Warning: fwrite() expects parameter 1 to be resource, string given in - on line 13

Call Stack:
0.2043 775464 1. {main}() -:0
0.2043 775464 2. Installer::run() -:3
0.2043 775464 3. Installer::checkRequirements() -:8
0.2044 776360 4. Installer::assert() -:10
0.2044 776360 5. Installer::warn() -:9
0.2046 776616 6. fwrite() -:13

Downloading...
Done!

Only update within same major version

The Box application must only be able to update within its own major version.

If a new major version is available, an option like --upgrade must be used.

This will prevent somebody from upgrading from 1.0 to 2.0, and potentially breaking their PHAR building setup.

This will affect the update command and the installer script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.