Download the PHP package donatorsky/vendor-compress without Composer

On this page you can find all versions of the php package donatorsky/vendor-compress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package 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 Build

What does it do?

Basically, it packs the content of vendor/ directory into single PHAR file, 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

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

Arguments:

Argument Description
path Path to the project or vendor directory from which generate PHAR. If not provided, current project is used.

Options:

Option Description
-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 message

Then use it:

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:

You can create your own .vendor_compress or .vendor_compress.dist configuraton file in working directory (usually project's root directory) or specify path to the configuration file using --configuration option. Tthe order of loading configurationis:

Available configuration options

Below is the list of all available options.

setFilesCompressionMethod(int $filesCompressionMethod)

Allows to set compression method that will be used for compressing each file individually. $filesCompressionMethod should be one of supported compressions available via \Phar::CONSTANT constant.

setArchiveCompressionMethod(int $archiveCompressionMethod)

Allows to set compression method that will be used for compressing whole file. The difference between setFilesCompressionMethod() is that with this option, the whole archive will be compressed at once at the end. It may be more efficient to do this in that way (see comparison below). $archiveCompressionMethod should be one of supported compressions available via \Phar::CONSTANT constant.

setAlias(string $alias)

Allows to alias with which generated Phar archive should be referred to in calls to stream functionality. See more at: https://secure.php.net/manual/en/phar.construct.php.

addExcluded(\Donatorsky\VendorCompress\Contracts\FileFilterInterface $fileFilter)

Allows to add file/directory exclusion rule used for vendor files list generation. There are already some rules included (see src/FileFilters/) that You can use, or write Your own.

setExcluded(\Donatorsky\VendorCompress\Contracts\FileFilterInterface[] $fileFilters)

Allows to set multiple file/directory exclusion rules at once. This overrides existing list of rules.

addIncluded(\Donatorsky\VendorCompress\Contracts\FileFilterInterface $fileFilter)

Allows to add file/directory inclusion rule used for vendor files list generation. There are already some rules included (see src/FileFilters/) that You can use, or write Your own. Inclusion rules have higher priority than exclusions. However there is something tricky worth mentioning:

setIncluded(\Donatorsky\VendorCompress\Contracts\FileFilterInterface[] $fileFilters)

Allows to set multiple file/directory inclusion rules at once. This overrides existing list of rules.

addFileProcessor(\Donatorsky\VendorCompress\Contracts\FileProcessorInterface $fileProcessor, \Donatorsky\VendorCompress\Contracts\FileFilterInterface $fileFilter, ...$moreFileFilters)

There are also file processors. They define some file content manipulations that should be performed before it is added to the archive. Eg. You can minify PHP code. It is possible to define multiple file rules to which content manipulation should be applied to.

Compression ratio comparison

Initial vendor/ size: 43.348 MiB

Number of files: 9664

Number of files after exclusions: 6992

Files \ Archive compression NONE GZ BZ2
NONE 26.731 MiB (61.7%) 6.914 MiB (15.9%) 5.885 MiB (13.6%)
GZ 8.788 MiB (20.3%) 8.313 MiB (19.2%) 8.356 MiB (19.3%)
BZ2 8.517 MiB (19.6%) 7.947 MiB (18.3%) 7.957 MiB (18.4%)

Note: Only by removing docs and tests (mainly) the size of vendor decreases by ~38%.

TODO: Add some generation times to comparison above.

Exit codes

All exit codes constants can be found in bin/constants.php file.

Exit code Name Description
0 VENDOR_COMPRESS_ERR_OK No error.
1 VENDOR_COMPRESS_ERR_UNSUPPORTED_PHP_VERSION Returned when minimum PHP version requirement is not fulfilled.
2 VENDOR_COMPRESS_ERR_MISSING_PHAR_CLASS Returned when \Phar class is missing.
3 VENDOR_COMPRESS_ERR_PROJECT_NOT_SET_UP Returned when vendor directory could not be found or composer install is not performed.
4 VENDOR_COMPRESS_ERR_CANNOT_WRITE_PHAR_FILES Returned when PHAR files writing is not allowed (according to https://secure.php.net/manual/en/phar.canwrite.php).
5 VENDOR_COMPRESS_ERR_MISSING_REQUIRED_OPTION_VALUE Returned when command option is passed without its required value.
6 VENDOR_COMPRESS_ERR_UNKNOWN_OPTION Returned when unknown command option is passed.
7 VENDOR_COMPRESS_ERR_UNKNOWN_ARGUMENT Returned when unknown command argument is passed.
8 VENDOR_COMPRESS_ERR_MISSING_REQUIRED_ARGUMENT_VALUE Returned when command argument is passed without its required value.
9 VENDOR_COMPRESS_ERR_COULD_NOT_DELETE_VENDOR_PHAR Returned when vendor.phar.[.*] file could not be removed.
10 VENDOR_COMPRESS_ERR_COULD_NOT_CREATE_VENDOR_PHAR Retuend when there is an error during Phar generation. The error message is sent to stderr.
11 VENDOR_COMPRESS_ERR_INACCESSIBLE_VENDOR_PATH Returned when path to vendor directory is invalid or inaccessible.
12 VENDOR_COMPRESS_ERR_INACCESSIBLE_CONFIGURATION_FILE Returned when specified configuration file could not be found or accessed.
13 VENDOR_COMPRESS_ERR_INVALID_CONFIGURATION_FILE Returned when configuration file is invalid (i.e. it is not an instance of \Donatorsky\VendorCompress\Config class).

Tips for use

Plans for future


All versions of vendor-compress with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-phar Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package donatorsky/vendor-compress contains the following files

Loading the files please wait ....