Giter VIP home page Giter VIP logo

phar-composer's Introduction

clue/phar-composer

CI status downloads on GitHub installs on Packagist

Simple phar creation for any project managed via Composer.

It takes your existing project's composer.json and builds an executable phar for your project among with its bundled dependencies.

  • Create a single executable phar archive, including its dependencies (i.e. vendor directory included)
  • Automated build process
  • Zero additional configuration

Table of contents

Support us

We invest a lot of time developing, maintaining and updating our awesome open-source projects. You can help us sustain this high-quality of our work by becoming a sponsor on GitHub. Sponsors get numerous benefits in return, see our sponsoring page for details.

Let's take these projects to the next level together! ๐Ÿš€

Usage

Once clue/phar-composer is installed, you can use it via command line like this.

phar-composer

This tool supports several sub-commands. To get you started, you can now use the following simple command:

$ phar-composer

This will actually execute the search command that allows you to interactively search and build any package listed on packagist (see below description of the search command for more details).

phar-composer build

The build command can be used to build an executable single-file phar (php archive) for any project managed by composer:

$ phar-composer build ~/path/to/your/project

The second argument can be pretty much everything that can be resolved to a valid project managed by composer. Besides creating phar archives for locally installed packages like above, you can also easily download and bundle packages from packagist.org like this:

$ phar-composer build d11wtq/boris

The above will download and install the latest stable tagged release (if any). You can also specify a tagged version like this:

$ phar-composer build clue/phar-composer:~1.0

Or you can specify to install the head of a given branch like this:

$ phar-composer build clue/phar-composer:dev-master

A similar syntax can be used to clone a package from any git URL. This is particularly useful for private packages or temporary git clones not otherwise listed on packagist:

$ phar-composer build https://github.com/composer/composer.git

The above will clone the repository and check out the default branch. Again, you can specify either a tag or branch name very similar to how composer works:

$ phar-composer build https://github.com/composer/composer.git:dev-master

phar-composer install

The install command will both build the given package and then install it into the system-wide bin directory /usr/local/bin (usually already in your $PATH). This works for any package name or URL just like with the build command, e.g.:

$ phar-composer install phpunit/phpunit

After some (lengthy) build output, you should now be able to run it by just issuing:

$ phpunit

In essence, the install command will basically just issue a build and then sudo mv $target.phar /usr/local/bin/$target. It will ask you for your sudo password when necessary, so it's not needed (and in fact not recommended) to run the whole comamnd via sudo.

Windows limitation: Note that this subcommand is not available on Windows. Please use the build command and place Phar in your $PATH manually.

phar-composer search

The search command provides an interactive command line search. It will ask for the package name and issue an search via packagist.org's API and present a list of matching packages. So if you don't know the exact package name, you can use the following command:

$ phar-composer search boris

It uses an interactive command line menu to ask you for the matching package name, its version and will then offer you to either build or install it.

Install

You can grab a copy of clue/phar-composer in either of the following ways.

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 8+. It's highly recommended to use the latest supported PHP version for this project.

As a phar (recommended)

You can simply download a pre-compiled and ready-to-use version as a Phar to any directory. You can simply download the latest phar-composer.phar file from our releases page. The latest release can always be downloaded like this:

$ curl -JOL https://clue.engineering/phar-composer-latest.phar

That's it already. Once downloaded, you can verify everything works by running this:

$ cd ~/Downloads
$ php phar-composer.phar --version

The above usage examples assume you've installed phar-composer system-wide to your $PATH (recommended), so you have the following options:

  1. Only use phar-composer locally and adjust the usage examples: So instead of running $ phar-composer --version, you have to type $ php phar-composer.phar --version.

  2. Use phar-composer's install command to install itself to your $PATH by running:

    $ php phar-composer.phar install clue/phar-composer
  3. Or you can manually make the phar-composer.phar executable and move it to your $PATH by running:

$ chmod 755 phar-composer.phar
$ sudo mv phar-composer.phar /usr/local/bin/phar-composer

If you have installed phar-composer system-wide, you can now verify everything works by running:

$ phar-composer --version

There's no separate update procedure, simply download the latest release again and overwrite the existing phar.

Again, if you have already installed phar-composer system-wide, updating is as easy as running a self-installation like this:

$ phar-composer install clue/phar-composer

Installation using Composer

Alternatively, you can also install phar-composer as part of your development dependencies. You will likely want to use the require-dev section to exclude phar-composer in your production environment.

You can either modify your composer.json manually or run the following command to include the latest tagged release:

$ composer require --dev clue/phar-composer

Now you should be able to invoke the following command in your project root:

$ vendor/bin/phar-composer --version

Note: You should only invoke and rely on the main phar-composer bin file. Installing this project as a non-dev dependency in order to use its source code as a library is not supported.

To update to the latest release, just run composer update clue/graph-composer.

Development

clue/phar-composer is an open-source project and encourages everybody to participate in its development. You're interested in checking out how clue/phar-composer works under the hood and/or want to contribute to the development of clue/phar-composer? Then this section is for you!

The recommended way to install clue/phar-composer is to clone (or download) this repository and use Composer to download its dependencies. Therefore you'll need PHP, Composer, git and curl installed. For example, on a recent Ubuntu/Debian-based system, simply run:

$ sudo apt install php-cli git curl

$ git clone https://github.com/clue/phar-composer.git
$ cd phar-composer

$ curl -s https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer

$ composer install

You can now verify everything works by running clue/phar-composer like this:

$ php bin/phar-composer --version

If you want to distribute clue/phar-composer as a single standalone release file, you may compile the project into a single phar-composer.phar file like this:

$ composer build

Note that compiling will temporarily install a copy of this project to the local build/ directory and install all non-development dependencies for distribution. This should only take a second or two if you've previously installed its dependencies already. The build script optionally accepts the version number (VERSION env) and an output file name or will otherwise try to look up the last release tag, such as phar-composer-1.0.0.phar.

You can now verify the resulting phar-composer.phar file works by running it like this:

$ php phar-composer.phar --version

To update your development version to the latest version, just run this:

$ git pull
$ composer install

Made some changes to your local development version?

Make sure to let the world know! :shipit: We welcome PRs and would love to hear from you!

Happy hacking!

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

$ composer install

To run the test suite, go to the project root and run:

$ vendor/bin/phpunit

License

This project is released under the permissive MIT license.

This project bundles the StubGenerator and Extract classes with minor changes from the original herrera-io/box v1.6.1 licensed under MIT which no longer has an installable candidate. Copyright (c) 2013 Kevin Herrera.

Did you know that I offer custom development services and issuing invoices for sponsorships of releases and for contributions? Contact me (@clue) for details.

phar-composer's People

Contributors

clue avatar icedream avatar mikey179 avatar paulrotmann avatar radford avatar simonfrings avatar staabm avatar szepeviktor avatar thojou 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

phar-composer's Issues

Add option to control verbosity and reduce default verbosity

We should add more CLI options to control the verbosity. Ideally, it would work somewhat similar to composer itself. Also, we should reduce the default verbosity and remove some of the less urgent messages.

-q / --quiet
-v / --verbose
-vv
-vvv

appends when executed multiple times

It seems when I run it locally multiple times it appends the same content to the same phar.

โžœ  Project git:(master) โœ— php -d phar.readonly=off ./tools/phar-composer.phar build .
[1/1] Creating phar project.phar
  - Adding main package "eftec/project"
  - Adding composer base files
  - Setting main/stub
    Using referenced chmod 0644
    Applying chmod 0644
  - Overwriting existing file project.phar (5470.5 KiB)

    OK - Creating project.phar (10941.1 KiB) completed after 1s
โžœ  Project git:(master) โœ— php -d phar.readonly=off ./tools/phar-composer.phar build .
[1/1] Creating phar project.phar
  - Adding main package "eftec/project"
  - Adding composer base files
  - Setting main/stub
    Using referenced chmod 0644
    Applying chmod 0644
  - Overwriting existing file project.phar (10941.1 KiB)

    OK - Creating project.phar (16411.7 KiB) completed after 1.1s
โžœ  Project git:(master) โœ— php -d phar.readonly=off ./tools/phar-composer.phar build .
[1/1] Creating phar project.phar
  - Adding main package "eftec/project"
  - Adding composer base files
  - Setting main/stub
    Using referenced chmod 0644
    Applying chmod 0644
  - Overwriting existing file project.phar (16411.7 KiB)

    OK - Creating project.phar (21882.3 KiB) completed after 1.4s

Re-enable GUI

An experimental GUI based on https://github.com/clue/reactphp-zenity has been merged with #13 quite some time ago. Unfortunately it never quite reached a state in which this should be part of this project. Also, it introduces a dependency on ext-posix which I'd like to avoid.

For now, we're going to drop the dependency again (effectively reverting #13).

This ticket serves as a reminder to re-enable the GUI feature once it's in a usable state.

help command

php phar-composer.phar directly starts the app in an interactive mode.

Usually CLI binaries output a help page when opened without any args, not sure this would make sense for phar-composer though.

One thing which bugs me even more is that php phar-composer.phar help does not contain any output about available commands. ATM it looks like the default symfony cli args, but nothing phar-composer related:

$ php phar-composer.phar help
Usage:
 help [--xml] [--format="..."] [--raw] [command_name]

Arguments:
 command               The command to execute
 command_name          The command name (default: "help")

Options:
 --xml                 To output help as XML
 --format              To output help in other formats (default: "txt")
 --raw                 To output raw command help
 --help (-h)           Display this help message.
 --quiet (-q)          Do not output any message.
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output,
2 for more verbose output and 3 for debug
 --version (-V)        Display this application version.
 --ansi                Force ANSI output.
 --no-ansi             Disable ANSI output.
 --no-interaction (-n) Do not ask any interactive question.

Help:
 The help command displays help for a given command:

   php phar-composer.phar help list

 You can also output the help in other formats by using the --format option:

   php phar-composer.phar help --format=xml list

 To display the list of available commands, please use the list command.

Status on the project?

Is this still maintained or was this abandoned?

theres pull requests open since last year, a lot of issues never touched, no releases after the last commits (and those quite a while ago)..

self-installation broken

wget http://www.lueck.tv/phar-composer/phar-composer.phar
php phar-composer.phar install clue/phar-composer 

gets into

      - Installing symfony/process (v2.4.1)
        Loading from cache

    Generating autoload files

    OK - Downloading package completed (after 2.4s)
[2/2] Creating phar phar-composer.phar
  - Remove existing file phar-composer.phar (1892.8 KiB)
PHP Warning:  include(phar:///home/sheershoff/phar-composer.phar/vendor/herrera-io/box/src/lib/Herrera/Box/Box.php): failed to open stream: phar error: Cannot open phar archive "/home/sheershoff/phar-composer.phar" for reading in phar:///home/sheershoff/phar-composer.phar/vendor/composer/ClassLoader.php on line 378

obviously, the problem is that the running copy deletes itself.

the work-around is

mkdir tmp && cd tmp && wget http://www.lueck.tv/phar-composer/phar-composer.phar && cd .. && php tmp/phar-composer.phar install clue/phar-composer 

Add support for running on systems without Phar extension

Ideally, the resulting phar files should also be executable on systems that do not have the Phar extension enabled. (This is not about adding support for creating phars without the Phar extension.)

Once box-project/box2-lib#4 is fixed, we should add an option to add the compatibility layer for systems with no phar support.

This is mainly larger file size (around +8KiB) vs better compatibility.

Something is running /tmp/phpd.local and hangs forever with 100% CPU

Hi, I have a weird problem in my Digital Ocean host. I still don't know who creates and starts the script /tmp/phpd.local but when it is done it hangs the CPU forever, if I don't enter the server and kill it other instances are executed as if there is no locking mechanism.

After opening the file I followed the URL and arrived at this page. A copy of the file is at:
http://alexa.pro.br/~bruno/phpd.local.txt

The host is a Debian system, I don't recall ever installing composer as I don't use it. Is there any way to track the origin of this file so I can remove the offending package? Or is this a known issue that can be fixed somehow?

Automatic search for main bin

Currently, we only try to take the first bin listed in composer.json. Aditionally, ticket #29 also aims for an explicit option.

However, often times projects to not define either value. For those projects, we should consider to automatically search a number of common locations such as:

  • bin/project
  • bin/project.php
  • project.php
  • index.php

Does not accept version ranges when building external packages

Example for docs doesn't work

php -d phar.readonly=off phar-composer-1.1.0.phar build clue/phar-composer:~1.0

Output

[1/3] Cloning clue/phar-composer:~1.0 into temporary directory /tmp/phar-composer5

    Cloning into '/tmp/phar-composer5'...
    fatal: 'clue/phar-composer:~1.0' does not appear to be a git repository
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.



  [UnexpectedValueException]
  Error status code: Invalid exit argument (code 128)



build [project] [target]

Explicitly define a main bin file

Currently, we only try to take the first bin listed in composer.json.

Aditionally, we should offer a way to define a main file either through a command line option or a config key extra.phar.main.

Do not add require-dev packages by default

So I made a simple "hack" so it only adding requires and not require-devs.

I read in one of the other issues (actually this was a PR #50 ), that it was a good thing to use composer/installed.json because this also had verions.

So I took the best of both worlds.

First load the required package into a list

        // Load composer.lock requires
        $requiredPackages = [];
        if (is_file($pathVendor . '../composer.lock')) {
            $compoaserPackages = $this->loadJson($pathVendor . '../composer.lock');
            foreach($compoaserPackages['packages'] as $pack) {
                $requiredPackages[$pack['name']] = true;
                if (isset($pack['require'])) {
                    foreach($pack['require'] as $key => $tmp)
                    $requiredPackages[$key] = true;
                }
            }
        }

And inside the loader of the getPackagesDependencies method just add 3 lines to the installed.json loader.

So getPackagesDependencies in my version looks like this
(The loader for the required packages should properly be put into a private method)

public function getPackagesDependencies()
    {
        $packages = array();

        $pathVendor = $this->getPathVendor();

        // Load composer.lock requires
        $requiredPackages = [];
        if (is_file($pathVendor . '../composer.lock')) {
            $compoaserPackages = $this->loadJson($pathVendor . '../composer.lock');
            foreach($compoaserPackages['packages'] as $pack) {
                $requiredPackages[$pack['name']] = true;
                if (isset($pack['require'])) {
                    foreach($pack['require'] as $key => $tmp)
                    $requiredPackages[$key] = true;
                }
            }
        }

        // load all installed packages (use installed.json which also includes version instead of composer.lock)
        if (is_file($pathVendor . 'composer/installed.json')) {
            // file does not exist if there's nothing to be installed
            $installed = $this->loadJson($pathVendor . 'composer/installed.json');

            foreach ($installed as $package) {
                if (! isset($requiredPackages[$package['name']])) {
                    continue;
                }

                $dir = $package['name'] . '/';
                if (isset($package['target-dir'])) {
                    $dir .= trim($package['target-dir'], '/') . '/';
                }

                $dir = $pathVendor . $dir;
                $packages [] = new Package($package, $dir);
            }
        }

        return $packages;
    }

For mine 2 projects this actually works perfect, and gives me a 1/3 sized phar file.

Are you interested in a PR ?

Error on Microsoft Windows for install command (UnexpectedValueException: Error status code: General error (code 1))

i used the workaround (proposed in issue 51).

I created tmp folder. I copier the in this folder and launch :

php tmp/phar-composer.phar install clue/phar-compser

i have error on end of the launch :

C:\Users\P054122-dev\Downloads>php tmp/phar-composer.phar install clue/phar-comp
oser
[1/2] Installing clue/phar-composer to temporary directory C:\Users\P05412~1\App
Data\Local\Temp/phar-composer7 (using C:\ProgramData\ComposerSetup\bin\composer.
BAT create-project "clue/phar-composer" "C:\Users\P05412~1\AppData\Local\Temp/ph
ar-composer7" --no-dev --no-progress --no-scripts)

      - Installing clue/phar-composer (v1.0.0)
        Loading from cache

    Created project in C:\Users\P05412~1\AppData\Local\Temp/phar-composer7
    Loading composer repositories with package information
    Installing dependencies from lock file
      - Installing guzzle/parser (v3.8.0)
        Loading from cache

      - Installing symfony/event-dispatcher (v2.4.1)
        Loading from cache

      - Installing guzzle/common (v3.8.0)
        Loading from cache

      - Installing guzzle/stream (v3.8.0)
        Loading from cache

      - Installing phine/exception (1.0.0)
        Loading from cache

      - Installing phine/path (1.1.0)
        Loading from cache

      - Installing herrera-io/box (1.5.1)
        Loading from cache

      - Installing guzzle/http (v3.8.0)
        Loading from cache

      - Installing doctrine/inflector (v1.0)
        Loading from cache

      - Installing knplabs/packagist-api (v1.1)
        Loading from cache

      - Installing symfony/console (v2.4.1)
        Loading from cache

      - Installing symfony/finder (v2.4.1)
        Loading from cache

      - Installing symfony/process (v2.4.1)
        Loading from cache

    Generating autoload files

    OK - Downloading package completed (after 11.9s)
[2/2] Creating phar phar-composer.phar
  - Remove existing file phar-composer.phar (1906.1 KiB)
  - Adding main package
    adding "C:\Users\P054122-dev\AppData\Local\Temp\phar-composer7/bin/phar-comp
oser"
    adding "C:\Users\P054122-dev\AppData\Local\Temp\phar-composer7/src/Clue/"
  - Adding composer base files
  - Adding dependency "guzzle/parser" from "vendor/guzzle/parser/Guzzle/Parser/"

    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/guzzle/parser/Guzzle/Parser/"
  - Adding dependency "symfony/event-dispatcher" from "vendor/symfony/event-disp
atcher/Symfony/Component/EventDispatcher/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/"
  - Adding dependency "guzzle/common" from "vendor/guzzle/common/Guzzle/Common/"

    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/guzzle/common/Guzzle/Common/"
  - Adding dependency "guzzle/stream" from "vendor/guzzle/stream/Guzzle/Stream/"

    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/guzzle/stream/Guzzle/Stream/"
  - Adding dependency "phine/exception" from "vendor/phine/exception/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/phine/exception/"
  - Adding dependency "phine/path" from "vendor/phine/path/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/phine/path/"
  - Adding dependency "herrera-io/box" from "vendor/herrera-io/box/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/herrera-io/box/"
  - Adding dependency "guzzle/http" from "vendor/guzzle/http/Guzzle/Http/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/guzzle/http/Guzzle/Http/"
  - Adding dependency "doctrine/inflector" from "vendor/doctrine/inflector/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/doctrine/inflector/"
  - Adding dependency "knplabs/packagist-api" from "vendor/knplabs/packagist-api
/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/knplabs/packagist-api/"
  - Adding dependency "symfony/console" from "vendor/symfony/console/Symfony/Com
ponent/Console/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/symfony/console/Symfony/Component/Console/"
  - Adding dependency "symfony/finder" from "vendor/symfony/finder/Symfony/Compo
nent/Finder/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/symfony/finder/Symfony/Component/Finder/"
  - Adding dependency "symfony/process" from "vendor/symfony/process/Symfony/Com
ponent/Process/"
    Adding whole project directory "C:\Users\P054122-dev\AppData\Local\Temp\phar
-composer7/vendor/symfony/process/Symfony/Component/Process/"
  - Setting main/stub
    Using referenced shebang "#!/usr/bin/env php"
    Using referenced chmod 0666
    Applying chmod 0666

    OK - Creating phar-composer.phar (1906.1 KiB) completed after 101.2s
Move resulting phar to /usr/local/bin




  [UnexpectedValueException]
  Error status code: General error (code 1)



install [name] [path]

Add support for excluding files

Now that v0.0.2 lays the foundation for handling each sub-package independently, we should add an config option to exclude a set of files from the resulting phar.

Ideally, each project should be able to specify which files are to be excluded separately, with one project not affecting any other project's exclude config.

Slow performance

I have this

build /.
...
OK - Creating project.phar (46010.5 KiB) completed after 8686.3s

Regarding source files I have 15~ dependencies such as symfony or doctrine.
What could I do to fix this for at least few minutes?

Problems due to double slash

I tried to package this library https://github.com/kzykhys/Ciconia

Ended with this message:

[BadMethodCallException]
  Entry src//Ciconia/Ciconia.php does not exist and cannot be created: phar error: invalid path "src//Ciconia/Ciconia.php" contains double slash

It was easy to fix, just had to remove the / after src in composer.json, but maybe it would be nice if this was handled automatically.

Use --no-dev When Building

I just ran this on one of my own libraries to see how it would work (neat, btw!) and found that it pulled in development dependencies into the generated phar. It would be nice to have an option to leave off dev dependencies from the built phar file. It would be nicer still to (eventually) have that be the default and there be an option to explicitly include dev dependencies.

Increase default process timeout

Currently, we're not explicitly specifying a timeout to symfony's process manager when launching composer to install dependencies. As such, it assumes a default timeout of 60s.

Depending on the internet connection, using composer to install e.g. phpunit/phpunit takes too long and hence the process will be interrupted.

We should remove the timeout altogether.

Steps to reproduce:

$ phar-composer install phpunit/phpunit:3.7.*
[1/2] Installing phpunit/phpunit:3.7.* to temporary directory /tmp/phar-composer7 (using /usr/local/bin/composer create-project 'phpunit/phpunit:3.7.*' '/tmp/phar-composer7' --no-dev --no-progress --no-scripts)

    Installing phpunit/phpunit (3.7.32)
      - Installing phpunit/phpunit (3.7.32)
    Failed to download phpunit/phpunit from dist: You must enable the openssl extension to download files via https
    Now trying to download from source
      - Installing phpunit/phpunit (3.7.32)
        Cloning 2752cbb9ea5bd84c2811b34b6953f76965ec7a2f


  [Symfony\Component\Process\Exception\RuntimeException]  
  The process timed-out.                                  



install [name] [path]

Git writing status to STDERR is interpreted as an error

After upgrading to Ubuntu 14.04 LTS phar-composer no longer works because of some changes in git.

Git writes its status output to STDERR, which is being interpreted as an error by phar-composer (which obviously, it is not).

The fix should be trivial: Just pass STDERR through to STDOUT and do not complain.

$ phar-composer build https://github.com/clue/phar-composer.git
Your configuration disabled writing phar files (phar.readonly = On), please update your configuration or run with "php -d phar.readonly=off /usr/local/bin/phar-composer", trying to re-spawn with correct config
[1/3] Cloning https://github.com/clue/phar-composer.git into temporary directory /tmp/phar-composer1

    Cloning into '/tmp/phar-composer1'...

  [UnexpectedValueException]  
  Error output present

build [path] [target]

Always add stub (even when no index file is defined)

Currently, the stub will not be added when no main index file is defined. As such, PHP's less versatile default stub will be added, which, among others, does not properly support systems without ext-phar.

Steps to reproduce:

# build a phar with no main file
$ phar-composer build erik-dubbelboer/php-redis-admin:dev-master bad.phar
# execute on a platform without ext-phar
$ php-pharless bad.phar
ERROR: manifest length read was "1553257" should be "35323904"

extract command

for debugging reaons it is sometimes required to extract the created .phar to see the contents of it.

would be great to have a command doing just that.

$phar = new Phar($pathToPhar);
$phar->extractTo($destPath);

validate composer.json

phar-composer commands assume the composer.json provided is valid.

In case it is not valid it sometimes produces strange things, e.g. name a project "myproject" (without a vendor prefix, which of course is invalid).
-> it will create a "yproject.phar" (without the leading "m"). It took some time to find out, that this problems are caused by my invalid composer.json.

phar-composer could do a better job and do a composer validate before each runs its own commands. In case of errors, skip its own command and print the error.

Build/deploy phar automatically (travis artifact, etc.)

This isn't quite the focus of this project, but it should be addressed nevertheless. This is what most users are likely going to look for.

The current steps to build and deploy a project are:

  1. Install project composer install vendor/project
  2. Install phar-composer (as per README): $ wget http://www.lueck.tv/phar-composer/phar-composer.phar
  3. Run php phar-composer.phar build . to generate a new project.phar
  4. Upload the phar to any hosting service and get its URL
  5. (Update README.md to reflect new download URL)

Obviously, this should be automated. Possible solutions:

How to create executable?

I have:
WARNING: No main bin file defined! Resulting phar will NOT be executable
How can I prevent this?
Thanks

Include/require errors

I'm not certain this project is still maintained, but I've tried using it to generate several phars, and they all build (and even install) successfully...but when executed, they print a bunch of warnings, and finally die with a fatal error trying to load classes from their vendor dependencies:

https://gist.github.com/EvanK/2c3f9ca429d995ea0989

Any clue what's causing this? I've tried with several packages, including phpunit and paratest

why is they a $web = 'index.php'; in the generated phar

Is they any way to suppress the $web = 'index.php'; from being added.
I get this error when requiring the phar
Warning: include(phar://C:\_SOAR_HOME\repository\_phar\packages56\laravel54.phar/index.php): failed to open stream: phar error: "index.php" is not a file in phar "C:/_SOAR_HOME/repository/_phar/packages56/laravel54.phar" in C:\_SOAR_HOME\repository\_phar\packages56\laravel54.phar on line 9

Add support to force extracting archives

Some packages are very difficult to bundle as a phar, most often because they work with their paths in a way that does not work within phars (most notably using realpath() etc.)

This should not be turned on by default for performance reasons, so we will need an additional config option.

Refs box-project/box2-lib#11

Build Libraries?

It looks like this project is meant to build an executable phar version of a project, like the Boris REPL. Can it also be used to build includable libraries?

It would be neat to be able to build a non-executable phar, with dependencies, for some given library and then be able to include that into a small or legacy project. The only rub I see is if multiple libraries are included this way that have overlapping dependency trees.

Roadmap to v2.0.0

It's my understanding that this project seems to work reasonably well for its intended use case - and at the same time fails to implement many of the nice-to-have features that were added over time.

As such, I'm planning to work towards a breaking v2.0.0 release to bring this project back to its basics: Building phar files for any project with as little configuration as possible.

In particular, this means that it will focus on building only and will not have any of the additional search and install commands anymore. This way, we can remove a significant piece of the current code base, no longer require any command line invocations (no composer, no git, no nothing) and focus on building the best tool to build a phar from a project directory.

On top of this, we may provide some documentation on how to build arbitrary projects by Composer package name or git repository, most of which can be achieved with a single line bash script.

I'm opening this ticket for the reference and to hopefully spark some discussion. I'm still working towards creating a feature/maintenance release for the v1 series, but future development will focus just on building phars.

Self-Installation fails using install command

Both installation from phar as installation from source fail when issueing the install command:

php phar-composer.phar install clue/phar-composer

The reason seems to be that herrera-io/box 1.5.0 is used instead of later versions, which tries to load herrera-io/file-system-functions (1.0.0). This library is not available anymore.

A successful workaround has been to chmod and move the phar for global installation.

Fix GUI for Zenity 3.8

Currently, running the gui does not work as expected with Zenity 3.8 anymore (shipped with Ubuntu 13.10 at least). Double-clicking items does not work anymore.

Fix already implemented in clue/reactphp-zenity@faa7923, opening this one just for the reference.

Update broken dependencies (herrera-io/file-system-functions)

Currently, running composer install fails due to a broken dependency:

$ composer install
โ€ฆ
  - Installing herrera-io/file-system-functions (1.0.0)
    Downloading: connection...
Could not fetch https://api.github.com/repos/herrera-io/php-fs-functions/zipball/1.0.0, enter your GitHub credentials to access private repos
The credentials will be swapped for an OAuth token stored in /home/clu/.composer/config.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username: xx
Password: xx
    Downloading: connection...


  [Composer\Downloader\TransportException]                                                        
  The "https://api.github.com/repos/herrera-io/php-fs-functions/zipball/1.0.0" file could not be  
   downloaded (HTTP/1.1 404 Not Found)

Empty meta projects with no source code fail (e.g. roave/security-advisories)

roave/security-advisories is a security package to conflict with known bad packages.

Thus it does not have a directory and causes an error:

  - Adding dependency "roave/security-advisories" from "vendor/roave/security-advisories/"


                                                                                               
  [InvalidArgumentException]                                                                   
  The "/Users/necrogami/code/mac/vendor/roave/security-advisories/" directory does not exist. 

Cache - Removed file trying to be loaded

Hi,

If you create a class, build the project into a .phar, and then remove the class, there is an error in the
vendor/composer/ClassLoader.php .

The removed file is still expected to be present, and I have removed all references to that class.
After a clear of composer and lots of phar-composer build launchs, it finally succeed.

I suspect there is a cache problem about this.

help unable to open some files

How to insert my assets file to my single executable phar?

// index.php
file_get_contents($this->assets.'/FSEX300.ttf');

u0_a115@localhost:$ ls simpleimage/ assets build composer.json composer.lock index.php src vendor u0_a115@localhost:$ php simpleimage.phar
Warning: imagettfbbox(): Invalid font filename in phar:///data/data/com.termux/files/home/simpleimage.phar/vendor/claviska/simpleimage/src/claviska/SimpleImage.php on line 928
Call Stack: 0.0600 641280 1. {main}() /data/data/com.termux/files/home/simpleimage.phar:0
0.0613 648120 2. include('phar:///data/data/com.termux/files/home/simpleimage.phar/index.php') /data/data/com.termux/files/home/simpleimage.phar:9 0.0809 980528 3. Gambar->__construct(???, ???, ???, ???, ???) phar:///data/data/com.termux/files/home/simpleimage.phar/index.php:71 0.3324 1287192 4. claviska\SimpleImage->text(???, ???, ???) phar:///data/data/com.termux/files/home/simpleimage.phar/index.php:56 0.3333 1287888 5. imagettfbbox(???, ???, ???, ???) phar:///data/data/com.termux/files/home/simpleimage.phar/vendor/claviska/simpleimage/src/claviska/SimpleImage.php:928
Unable to load font file: phar:///data/data/com.termux/files/home/simpleimage.phar/assets/FSEX300.ttf

u0_a115@localhost:~$

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.