Download the PHP package phine/compact without Composer
On this page you can find all versions of the php package phine/compact. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phine/compact
More information about phine/compact
Files in phine/compact
Package compact
Short Description A PHP library for compacting the contents of files.
License MIT
Homepage https://github.com/phine/lib-compact
Informations about the package compact
Compact
A PHP library for compacting the contents of files.
Requirement
- PHP >= 5.3.3
- Phine Exception >= 1.0.0
Installation
Via Composer:
$ composer require "phine/compact=~1.0"
Usage
The Compact library provides a consistent way of compacting files and their contents. The purpose of the library is simply to reduce the size of the contents without affecting how it is used. For example, compacting a JSON file would involve removing any excess whitespace that was used for "pretty printing".
Assuming we had this in example.json
:
The contents would then be compacted to:
Bundled Compactors
The library also includes the following compactor classes:
Phine\Compact\Json
— For compacting JSON files.Phine\Compact\Php
— For compacting PHP files.Phine\Compact\Xml
— For compacting XML files.
Creating a Compactor
The library includes an interface that all bundled classes implement. An
abstract class is also included, which all bundled compactor classes extend.
When you create your own compactor class, you will want to extend the
Phine\Compact\AbstractCompact
class.
When extending the AbstractCompact
class, the compactFile()
method will
already be implemented for you. It will rely on the compactContents()
method
to compact the contents after it has been read from the file.
Please considering adding your compactor class to the wiki.
Collections
If you need to manage multiple compactors, the library offers a Collection
class. In addition to the class, an interface is provided so that different
implementations can be supported.
Documentation
You can find the API documentation here.
License
This library is available under the MIT license.