PHPackages                             msomnium/vendor-packer - 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. msomnium/vendor-packer

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

msomnium/vendor-packer
======================

Package all vendor files into a single .phar file

0.1.0-alpha2(3mo ago)07↓92.9%MITPHP

Since Apr 3Pushed 3mo agoCompare

[ Source](https://github.com/ArielLeyva/vendor-packer)[ Packagist](https://packagist.org/packages/msomnium/vendor-packer)[ RSS](/packages/msomnium-vendor-packer/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (3)Used By (0)

---

VendorPacker
============

[](#vendorpacker)

 [ ![Composer Version](https://camo.githubusercontent.com/1aaeeefe4388b45494b420437238d0346ac0ce548662895e0bae92fa922ee21d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d736f6d6e69756d2f76656e646f722d7061636b65722e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/msomnium/vendor-packer) [ ![PHP Version](https://camo.githubusercontent.com/001dd4f14f2a0edff02d9e4778f810156797abf47eb6e1cd7a42e76fb528ba31/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344253230382e312d626c75652e7376673f7374796c653d666c61742d737175617265) ](https://www.php.net/) [ ![MIT License](https://camo.githubusercontent.com/458425f8985b0b0c8a736cffe75e05a098e3d77906acddbcad2bfc54492a4e02/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265) ](LICENSE)

VendorPacker is a Composer plugin that allows you to package your entire `vendor/` directory into a single `.phar` file.
It provides a clean workflow for packing, removing, regenerating, and recreating your dependencies, while keeping full compatibility with Composer and the PHP ecosystem.

1. [Installation](#installation)
2. [Usage Examples](#usage-examples)
3. [Available Commands](#available-commands)
    1. [`vendor:pack`](#1-vendorpack)
    2. [`vendor:update-autoload`](#2-vendorupdate-autoload)
    3. [`vendor:remove`](#3-vendorremove)
    4. [`vendor:regenerate`](#4-vendorregenerate)
    5. [`vendor:recreate`](#5-vendorrecreate)
4. [Optional Configuration Files](#optional-configuration-files)
    1. [`vendor-packer-config.json`](#vendor-packer-configjson)
    2. [`vendor-packer-stub.php`](#vendor-packer-stubphp)
5. [Limitations](#limitations)
6. [Advantages](#advantages)
7. [How It Works Internally](#how-it-works-internally)

VendorPacker is especially useful for:

- Deployments where the `vendor/` folder must be minimized or removed
- Hosting environments with file count limits
- Projects that need a portable, self‑contained dependency bundle
- Reducing deployment size and improving autoload performance
- Ensuring reproducible builds

---

Installation
------------

[](#installation)

VendorPacker is distributed as a Composer plugin and requires no global tools or manual setup. [Box](https://github.com/box-project/box) is bundled automatically as a dependency of the plugin.

```
composer require msomnium/vendor-packer
```

---

Usage Examples
--------------

[](#usage-examples)

Below are the most common workflows using VendorPacker.

```
composer vendor:pack
composer vendor:update-autoload
composer vendor:remove
```

These three commands package all your dependencies into a single `.phar` file, significantly reducing the number of inodes in your project.

All your dependencies remain available and you don't need to make any adjustments to your project.

---

Available Commands
------------------

[](#available-commands)

VendorPacker provides this commands into your Composer environment:

### **1. `vendor:pack`**

[](#1-vendorpack)

**Pack vendor folder content into a `.phar` file.**

```
composer vendor:pack
```

This command uses [Box](https://github.com/box-project/box) for compile your vendor content folder into a single `.phar` file. You can customize the Box compilation settings by creating a valid configuration file for the box in your project's root directory; the name of this file should be vendor-packer-config.json.

For example, this configuration creates a `.phar` file compressed with the BZ2 algorithm.

```
{
  "stub": "vendor-packer-stub.php",
  "directories": [
    "vendor"
  ],
  "output": "vendor/vendor-packer.phar",
  "compression": "BZ2"
}
```

Warning

The output file must always be `vendor/vendor-packer.phar`

By default, VendorPacker creates a [stub](https://github.com/box-project/box/blob/main/doc/configuration.md#stub) file for Box. This file only loads the autoload from the generated `.phar` file so that all dependencies are available. You can customize this behavior with a `vendor-packer-stub.php` file in your project's root directory.

---

### **2. `vendor:update-autoload`**

[](#2-vendorupdate-autoload)

**Update the `vendor/autoload.php` file to point to the new `.phar` file.**

```
composer vendor:update-autoload
```

This replaces the default Composer autoloader with a lightweight proxy that loads the `.phar` file generated instead of the physical vendor directory.

---

### **3. `vendor:remove`**

[](#3-vendorremove)

**Delete the entire `vendor/` folder content.**

```
composer vendor:remove
```

Remove all files and directories of your installed dependencies.

Warning

Use only after running vendor:pack

---

### **4. `vendor:regenerate`**

[](#4-vendorregenerate)

**Regenerate the `.phar` file from the current vendor folder content.**

```
composer vendor:regenerate
```

This is equivalent to re‑packing the vendor directory without reinstalling dependencies.

---

### **5. `vendor:recreate`**

[](#5-vendorrecreate)

**Reinstall all dependencies in your vendor folder.**

```
composer vendor:recreate
```

This command runs `composer install` in your project root, restoring a full vendor directory from scratch.

---

Optional Configuration Files
----------------------------

[](#optional-configuration-files)

VendorPacker supports two optional files in your project root:

### **`vendor-packer-config.json`**

[](#vendor-packer-configjson)

Custom Box configuration for advanced use cases. See the [Box Configuration](https://github.com/box-project/box/blob/main/doc/configuration.md) for more information.

If present, VendorPacker will use this file instead of generating its own default configuration.

You can use this to:

- Add custom finders
- Exclude or include specific files
- Modify PHAR metadata
- Override compression settings

---

### **`vendor-packer-stub.php`**

[](#vendor-packer-stubphp)

Custom PHAR stub file.

If present, VendorPacker will use your stub instead of the default one.
This allows you to:

- Customize the PHAR bootstrap process
- Load additional files before the autoloader
- Implement custom runtime logic
- Integrate with frameworks or custom loaders

---

Limitations
-----------

[](#limitations)

VendorPacker works with the vast majority of Composer packages, but there are rare edge cases:

1. **Packages that write into their own vendor subdirectory at runtime**

Some libraries (very uncommon) may:

- Generate cache files inside their own vendor folder
- Write temporary files next to their source code
- Expect writable paths inside `vendor/`

Since `.phar` files is read‑only, these packages may not behave correctly.

2. **PHAR extension deisabled**

VendorPacker uses the PHP PHAR extension for read operations; some shared hosting services or servers do not have the PHAR extension enabled; please verify that this extension is activated on your server or hosting provider.

3. **Write .phar file permission (partial limitation)**

Some servers or hosting providers disable writing to .phar files. In these cases, the `composer vendor:pack` and `composer vendor:regenerate` commands will not work. If you encounter this limitation, you can always generate the .phar file on your device and upload it to your server.

**Recommendation:**
Test thoroughly before deploying PHAR‑only mode.

---

Advantages
----------

[](#advantages)

VendorPacker provides several strong benefits:

- **Deployment simplicity**: Ship a single `.phar` file instead of thousands of files.
- **Faster deployments**: Copying one file is significantly faster than syncing an entire vendor tree.
- **Reduced file count**: Ideal for shared hosting, serverless, or inode‑limited environments.
- **Reproducible builds**: The PHAR ensures dependencies are packaged exactly as installed.
- **Cleaner project structure**: You can remove the vendor folder entirely after packing.
- **Fully reversible**: Restore the vendor directory anytime with `vendor:recreate`.
- **Higher performance**: Using a single .phar file to package dependencies makes Composer and PHP read operations faster.

---

How It Works Internally
-----------------------

[](#how-it-works-internally)

VendorPacker follows a simple and predictable workflow.
Here’s what happens inside your project when you run the three main commands:

#### **1. `composer vendor:pack`**

[](#1-composer-vendorpack)

This command creates the `vendor/vendor-packer.phar` file.

**Internal flow:**

1. VendorPacker generates a temporary Box configuration (unless you provide `vendor-packer-config.json`).
2. It loads your custom stub (`vendor-packer-stub.php`) or uses the default one.
3. It executes Box with the project root as the working directory.
4. Box scans the `vendor/` directory and packages it into `vendor/vendor-packer.phar`.
5. Temporary files are cleaned up.

**Result:**
Your entire vendor directory is now compressed into a single `.phar` file.

#### **2. `composer vendor:update-autoload`**

[](#2-composer-vendorupdate-autoload)

This command switches your project to PHAR‑based autoloading.

**Internal flow:**

1. VendorPacker replaces `vendor/autoload.php` with a lightweight proxy.
2. The proxy loads:

    ```
    phar://vendor/vendor-packer.phar/vendor/autoload.php

    ```
3. Your application now uses the PHAR’s internal autoloader instead of the physical vendor directory.

**Result:**
Your project runs using `vendor-packer.phar` transparently, without modifying your application code.

#### **3. `composer vendor:remove`**

[](#3-composer-vendorremove)

This command removes the physical vendor directory.

**Internal flow:**

1. VendorPacker deletes everything inside `vendor/`
2. It preserves only:
    - `vendor/vendor.phar`
    - `vendor/autoload.php` (the proxy)

**Result:**
Your project now runs entirely from the PHAR, with no vendor folder present.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance82

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e43a079215f2034ab58b293a6381dfade2e00caa2081316fea5982c22e0a313c?d=identicon)[msomnium](/maintainers/msomnium)

---

Top Contributors

[![ArielLeyva](https://avatars.githubusercontent.com/u/70982507?v=4)](https://github.com/ArielLeyva "ArielLeyva (4 commits)")

### Embed Badge

![Health badge](/badges/msomnium-vendor-packer/health.svg)

```
[![Health](https://phpackages.com/badges/msomnium-vendor-packer/health.svg)](https://phpackages.com/packages/msomnium-vendor-packer)
```

###  Alternatives

[symfony/runtime

Enables decoupling PHP applications from global state

74798.8M1.0k](/packages/symfony-runtime)[drupal/core-composer-scaffold

A flexible Composer project scaffold builder.

5445.2M565](/packages/drupal-core-composer-scaffold)[drupal/core-project-message

Adds a message after Composer installation.

2124.7M203](/packages/drupal-core-project-message)[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

3014.6M26](/packages/vaimo-composer-patches)[sandersander/composer-link

Adds ability to link local packages for development with composer

98457.9k](/packages/sandersander-composer-link)[phpro/grumphp-shim

GrumPHP Phar distribution

294.7M340](/packages/phpro-grumphp-shim)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
