PHPackages                             avto-dev/composer-cleanup-plugin - 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. avto-dev/composer-cleanup-plugin

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

avto-dev/composer-cleanup-plugin
================================

A composer cleanup plugin, to remove tests and documentation to save space

v3.0.4(10mo ago)740.8k↓38.8%5MITPHPPHP ^8.2CI passing

Since Jun 18Pushed 10mo agoCompare

[ Source](https://github.com/avto-dev/composer-cleanup-plugin)[ Packagist](https://packagist.org/packages/avto-dev/composer-cleanup-plugin)[ RSS](/packages/avto-dev-composer-cleanup-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (23)Used By (0)

 [![logo](https://camo.githubusercontent.com/338183301333aec9ee61f09e68b7e0de96c918f92db0522a10a0755553c42ced/68747470733a2f2f6873746f2e6f72672f776562742f716d2f76772f66312f716d767766316b683371796d7661646e657434676776745f7075652e706e67)](https://camo.githubusercontent.com/338183301333aec9ee61f09e68b7e0de96c918f92db0522a10a0755553c42ced/68747470733a2f2f6873746f2e6f72672f776562742f716d2f76772f66312f716d767766316b683371796d7661646e657434676776745f7075652e706e67)

Composer Cleanup Plugin
=======================

[](#composer-cleanup-plugin)

[![Version](https://camo.githubusercontent.com/b033459ffec0e8b86d627dd85d7002fe3465185ef865d28ca5ca42dbc2c4def1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6176746f2d6465762f636f6d706f7365722d636c65616e75702d706c7567696e2e7376673f6d61784167653d313830)](https://packagist.org/packages/avto-dev/composer-cleanup-plugin)[![Version](https://camo.githubusercontent.com/d248428ef572f08dd31e81212644319c2350837e4fd04dee02d16711f2f514f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6176746f2d6465762f636f6d706f7365722d636c65616e75702d706c7567696e2e7376673f6c6f6e6743616368653d74727565)](https://packagist.org/packages/avto-dev/composer-cleanup-plugin)[![Build Status](https://camo.githubusercontent.com/74bff4c1fc71af24898293995cd6d827fbc27f2f2174286a6ed29591acc9fe07/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6176746f2d6465762f636f6d706f7365722d636c65616e75702d706c7567696e2f74657374732e796d6c)](https://github.com/avto-dev/composer-cleanup-plugin/actions)[![Coverage](https://camo.githubusercontent.com/b62d91e55c957112c7c233e655e3a2c880d1b66c9364d5af463710b515914756/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6176746f2d6465762f636f6d706f7365722d636c65616e75702d706c7567696e2f6d61737465722e7376673f6d61784167653d3630)](https://codecov.io/gh/avto-dev/composer-cleanup-plugin/)[![Downloads count](https://camo.githubusercontent.com/8f2ca7d9364c6133976e41fb73cfa24693817bc0ebbc2fbb68fcadeb3b793583/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6176746f2d6465762f636f6d706f7365722d636c65616e75702d706c7567696e2e7376673f6d61784167653d313830)](https://packagist.org/packages/avto-dev/composer-cleanup-plugin)[![License](https://camo.githubusercontent.com/fd8626b984142be2a2f3777534f49392611bf212dc2862bee9a7e0199ebac36e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6176746f2d6465762f636f6d706f7365722d636c65616e75702d706c7567696e2e7376673f6c6f6e6743616368653d74727565)](https://github.com/avto-dev/composer-cleanup-plugin/blob/master/LICENSE)

Remove tests &amp; documentation from the vendor dir. Based on [barryvdh/composer-cleanup-plugin](https://github.com/barryvdh/composer-cleanup-plugin).

Usually disk size shouldn't be a problem, but when you have to use FTP to deploy or have very limited disk space, you can use this package to cut down the vendor directory by deleting files that aren't used in production (tests/docs etc).

> **Note:** This package is still experimental, usage in production without detailed tests is not recommended.

Install
-------

[](#install)

Require this package in your composer.json:

```
$ composer require avto-dev/composer-cleanup-plugin "^2.0"
```

Usage
-----

[](#usage)

If you are using `composer:v1` you need to add lines to run the clean command after each package is installed:

```
"post-package-install": [
    "AvtoDev\\Composer\\Cleanup\\Plugin::handlePostPackageInstallEvent"
],
```

If you use `composer:v2` then all packages are installed in parallel, so automatic cleanup occurs after all packages are installed and the event fires `POST_AUTOLOAD_DUMP`.

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

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

For every installed or updated package in the default list, in general:

1. Remove documentation, such as README files, docs folders, etc.
2. Remove tests, PHPUnit configs, and other build/CI configuration.

Some packages don't obey the general rules, and remove more/less files. Packages that do not have rules added are ignored.

Rules
-----

[](#rules)

Please submit a PR to [src/.clean\_rules.php](/.clean_rules.php) to add more rules for packages. Make sure you test them first, sometimes tests dirs are classmapped and will error when deleted.

If you need to optionally override the parameters of the cleaning rules, then create a `.clean_rules.php` file in the root of your application that returns an associated array of rules. If it exists, its content will be merged with the package config, optionally overriding the necessary rules. The config includes 4 properties: `global`, `packages`, `excluded_global`, `excluded_packages`.

#### Global

[](#global)

List of files ready for removal in each installed package.

#### Packages

[](#packages)

List of files and directories ready for deletion by package.

#### Excluded global

[](#excluded-global)

List of files that should be excluded from the deletion list.

#### Excluded Packages

[](#excluded-packages)

List of files and directories to exclude from deletion on a per-package basis.

### Full example

[](#full-example)

It should look like this:

```
