PHPackages                             donatorsky/vendor-compress - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. donatorsky/vendor-compress

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

donatorsky/vendor-compress
==========================

Compress vendor directory into one vendor.phar file

v2.0.1(7y ago)64.1k↓50%1[1 issues](https://github.com/donatorsky/vendor-compress/issues)MITPHPPHP &gt;=7.1

Since Dec 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/donatorsky/vendor-compress)[ Packagist](https://packagist.org/packages/donatorsky/vendor-compress)[ RSS](/packages/donatorsky-vendor-compress/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (4)Used By (0)

vendor-compress
===============

[](#vendor-compress)

Compress vendor directory into one vendor.phar file.

This is a project completely for fun and as a PoC. It is rather unusual to have to compress the vendor directory to save a few megabytes.

The idea for this project was born recently, when I had to work in a very restricted environment (server with 10 MiB disk space for a visit card page) and every byte counted. I decided to share this solution, maybe it will be useful to someone.

The package is created as minimal as possible.

[![GitHub license](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](https://github.com/donatorsky/vendor-compress/blob/master/LICENSE)[![Build](https://camo.githubusercontent.com/502c6ad395e5927bc7a755a86a9ab495d538e9c3fe03d6df8169e2539df52057/68747470733a2f2f7472617669732d63692e636f6d2f646f6e61746f72736b792f76656e646f722d636f6d70726573732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/donatorsky/vendor-compress)

What does it do?
----------------

[](#what-does-it-do)

Basically, it packs the content of `vendor/` directory into single [PHAR file](https://secure.php.net/manual/en/book.phar.php), optionally compressing it and performing other disk-space optimizations. And tries to make all of it working :)

The original `vendor/` directory is not removed nor modified!

How to use
----------

[](#how-to-use)

Generate vendor.phar (or vendor.phar.gz or vendor.phar.bz2 depending on configuration; see below) file:

```
bin/vendor-compress [options] []

```

Arguments:

ArgumentDescription`path`Path to the project or vendor directory from which generate PHAR. If not provided, current project is used.Options:

OptionDescription`-c, --configuration`Path to configuration file.`    --memory-limit`Set PHP memory limit for current run.`-o, --override`Defines to override vendor.phar file if it already exists. Without that, if file exists, the generation will not be performed.`-h, --help`Display the help message`-q, --quiet`Do not output any messageThen use it:

```
// Replace
require __DIR__ . 'vendor/autoload.php';

// With (add .gz/.bz2 if archive-compressed)
require __DIR__ . 'vendor.phar';

// Or replace with auto-detection of proper vendor source
is_file(__DIR__ . 'vendor.phar') ? require __DIR__ . 'vendor.phar' : require __DIR__ . 'vendor/autoload.php';
```

Configuration
-------------

[](#configuration)

For easier configuration managing, You can create dedicated file that will be loaded. It must return an instance of `\Donatorsky\VendorCompress\Config` class. There is one here (see `.vendor_compress.dist`) that works as a fallback if no configuration was provided:

```
