All Projects → mpyw → comphar

mpyw / comphar

Licence: MIT license
Pack all composer dependencies into a single phar file.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to comphar

Rtorrent Cleaner
🧹 rtorrent-cleaner is a tool to clean up unnecessary files in rtorrent
Stars: ✭ 36 (-46.27%)
Mutual labels:  composer, phar
Tooly Composer Script
Simple composer script to manage phar files using project composer.json.
Stars: ✭ 87 (+29.85%)
Mutual labels:  composer, phar
Pharbuilder
Create Phar of Composer based PHP application
Stars: ✭ 122 (+82.09%)
Mutual labels:  composer, phar
drupal8-composer-template
Project template for Drupal 8 projects with composer | Quick installation via "composer create-project woprrr/drupal8-composer-template:8.3.0"
Stars: ✭ 27 (-59.7%)
Mutual labels:  composer
autoload
Aplus Framework Autoload Library
Stars: ✭ 18 (-73.13%)
Mutual labels:  composer
tdee-calculator
TDEE Calculator is a composer library that calculates how much energy (calories) are burned daily given the weight, height and age or Lean Body Mass.
Stars: ✭ 16 (-76.12%)
Mutual labels:  composer
integration-test
ensure core packaging tools work well with each other
Stars: ✭ 15 (-77.61%)
Mutual labels:  packaging
composer-cost
Displays cost/size of each composer package installed.
Stars: ✭ 31 (-53.73%)
Mutual labels:  composer
wheelfile
🔪🧀 API for creating and inspecting Python .whl files (wheels).
Stars: ✭ 22 (-67.16%)
Mutual labels:  packaging
internetarchivebot
iabot.toolforge.org
Stars: ✭ 67 (+0%)
Mutual labels:  composer
VirionTools
A handy plugin for developers who wish to compile and inject virions without using Poggit.
Stars: ✭ 17 (-74.63%)
Mutual labels:  phar
python-deb-pkg-tools
Debian packaging tools
Stars: ✭ 36 (-46.27%)
Mutual labels:  packaging
product-packager
A portable shell program to package and prepare courses, tutorial series, and other products to release on e-commerce platforms like Gumroad and Mavenseed.
Stars: ✭ 42 (-37.31%)
Mutual labels:  packaging
poetry-setup
Generate setup.py (setuptools) from pyproject.toml (poetry)
Stars: ✭ 44 (-34.33%)
Mutual labels:  packaging
package-command
Lists, installs, and removes WP-CLI packages.
Stars: ✭ 16 (-76.12%)
Mutual labels:  composer
wp-skeleton
Setup a new WordPress installation via Composer
Stars: ✭ 36 (-46.27%)
Mutual labels:  composer
lilac
Lilac is the build bot for archlinuxcn
Stars: ✭ 87 (+29.85%)
Mutual labels:  packaging
winepak-sdk
Platform and SDK runtimes for winepak based applications
Stars: ✭ 46 (-31.34%)
Mutual labels:  packaging
stock-api-libphp
PHP implementation of the Stock APIs
Stars: ✭ 16 (-76.12%)
Mutual labels:  composer
ACCESS-NYC
Find help in NYC with food, money, housing, work, and more on ACCESS NYC. Maintained by @NYCOpportunity
Stars: ✭ 27 (-59.7%)
Mutual labels:  composer

Comphar

Composer + Phar

Pack all composer dependencies into a single phar file.

Installation

1. Execute composer global installation

Install via Packagist.

example@localhost:~$ composer global require mpyw/comphar:^1.0
Changed current directory to /Users/mpyw/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing mpyw/comphar (dev-master XXXXXXX)
    Cloning XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Writing lock file
Generating autoload files
example@localhost:~$

2. Update $PATH

If not yet, you must add ~/.composer/vendor/bin to $PATH.
Append the following statement to ~/.bashrc, ~/.zshrc and so on.

export PATH="~/.composer/vendor/bin:$PATH"

Usage

example@localhost:~$ comphar -h
Usage: ./comphar [options]
Options:
  -h, --help             Show help.
  -v, --verbose          Verbose output.
  -o, --out <value>      Output archive name. Default to "vendor.phar".
  -d, --dir <value>      Project root directory. Default to getcwd().
      --yes              Without confirmation.
example@localhost:~$

Example

1. Prepare your repository

Prepare composer.json.

{
    "name": "mpyw/my-new-package",
    "description": "This is a stupid example",
    "require": {
        "mpyw/my-dependency-1": "@dev",
        "mpyw/my-dependency-2": "1.0.0",
    },
    "autoload": {
        "psr-4": {
            "mpyw\\MyNewPackage\\": "src/"
        }
    }
}

2. Generate vendor.phar

Let's generate vendor.phar in that directory.

example@localhost:~/my-new-package$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
example@localhost:~/my-new-package$ comphar -v
Project directory: ~/my-new-package
Output filename: ~/my-new-package/vendor.phar
Continue? [y/n]: y
Added: ...
Added: ...
Added: ...
Added: ...
Added: ...
example@localhost:~/my-new-package$

Note

Even if you have no dependencies, you have to call composer install or composer update to adjust your own library to autoloading.

3. Enjoy

You can require vendor.phar as well as usual vendor/autoload.php.

Simplest usage

<?php
use mpyw\MyNewPackage\Foo;
require __DIR__ . '/vendor.phar';
$foo = new Foo();

Add your own autoloading

<?php
use mpyw\MyNewPackage\Foo;
use mpyw\MyOtherPackage\Bar;
$loader = require __DIR__ . '/vendor.phar';
$loader->addPsr4('mpyw\\MyOtherPackage\\', '~/my-other-package/src');
$foo = new Foo();
$bar = new Bar();

Error: Permission denied

It's possible you run into the error "Permission denied":

example@localhost:~/my-new-package$ comphar -v
Error: Permission denied: Disable "phar.readonly" and "phar.require_hash"

In this case, you need to adjust your configuration at the "php.ini":

[Phar]
; http://php.net/phar.readonly
phar.readonly = Off

; http://php.net/phar.require-hash
phar.require_hash = Off
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].