PHPackages                             index0h/yii2-phar - 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. index0h/yii2-phar

AbandonedArchivedYii2-extension[Utility &amp; Helpers](/categories/utility)

index0h/yii2-phar
=================

Phar builder based on Yii2

0.0.3(12y ago)6492[1 issues](https://github.com/index0h/yii2-phar/issues)MITPHPPHP &gt;=5.4.0

Since Jan 28Pushed 11y ago2 watchersCompare

[ Source](https://github.com/index0h/yii2-phar)[ Packagist](https://packagist.org/packages/index0h/yii2-phar)[ Docs](https://github.com/index0h/yii2-phar)[ RSS](/packages/index0h-yii2-phar/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

yii2-phar
=========

[](#yii2-phar)

[![Build Status](https://camo.githubusercontent.com/6e0b8fc1a1bd0d98b5da6bb0902a2cbedf38661de964b566ebb7c0e7aca00053/68747470733a2f2f7472617669732d63692e6f72672f696e64657830682f796969322d706861722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/index0h/yii2-phar) [![Latest Stable Version](https://camo.githubusercontent.com/6680752908112dd56432fa9c88c3b235f727c439992150e84f2893e1c9029580/68747470733a2f2f706f7365722e707567782e6f72672f696e64657830682f796969322d706861722f762f737461626c652e706e67)](https://packagist.org/packages/index0h/yii2-phar) [![Dependency Status](https://camo.githubusercontent.com/5436f417585e51c68c36a599780e5bf6ceb352743ea34a7919d0b0b3c41f9ed7/68747470733a2f2f67656d6e617369756d2e636f6d2f696e64657830682f796969322d706861722e706e67)](https://gemnasium.com/index0h/yii2-phar) [![Scrutinizer Quality Score](https://camo.githubusercontent.com/16db74e4c5fa08bd9815b6e4b9d7163310510954931a440b76fa608807cb9046/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696e64657830682f796969322d706861722f6261646765732f7175616c6974792d73636f72652e706e673f733d36343634393966386366636134363330313330646631623837396633366434626537333563623731)](https://scrutinizer-ci.com/g/index0h/yii2-phar/) [![Code Coverage](https://camo.githubusercontent.com/4296825e1d21fb64655261983de9cae9a6e2ce25d10bc4efe5cb0ced85061595/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696e64657830682f796969322d706861722f6261646765732f636f7665726167652e706e673f733d35336432323930653632396364633061376636356536376538633937396365633966393463666132)](https://scrutinizer-ci.com/g/index0h/yii2-phar/) [![Total Downloads](https://camo.githubusercontent.com/002c1e6866d059e55763665d20a243f441f87f24763d89399f9c2ec895fb9b34/68747470733a2f2f706f7365722e707567782e6f72672f696e64657830682f796969322d706861722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/index0h/yii2-phar) [![License](https://camo.githubusercontent.com/85d8ae95ed9ed43221db89afabc8c68084dbb81653bf14a0b3e61d26606279f2/68747470733a2f2f706f7365722e707567782e6f72672f696e64657830682f796969322d706861722f6c6963656e73652e706e67)](https://packagist.org/packages/index0h/yii2-phar)

This module provides console interface for building PHAR archives for Yii2 applications.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

```
php composer.phar require --prefer-dist index0h/yii2-phar "*"
```

or add line to require section of `composer.json`

```
"index0h/yii2-phar": "*"
```

Standalone usage
----------------

[](#standalone-usage)

- Installation

```
php composer.phar global require index0h/yii2-phar:*
```

- Running

```
yii2-phar
# Or with external configuration
yii2-phar phar/build myConfiguration.php
```

Usage
-----

[](#usage)

Once module is installed, modify your application configuration as follows:

```
return [
    'modules' => [
        'phar' => 'index0h\\phar\\Module',
        ...
    ],
    ...
];
```

You can access to yii2-phar module though console:

```
yii phar/build
```

Options
-------

[](#options)

- **compress** - Array of compress algorithms, \\Phar::GZ, \\Phar::BZ2. Creates compressed files of main phar.
- **files** - List of files to compile.
- **folders** - List of directories to compile.
- **ignore** - List of regexp patterns that must be ignored on build. That means if any file will match to any of patterns - it will be ignored.
- **path** - Path to phar file save.
- **pharName** - Phar name.
- **signature** - One of [Phar signature algorithms](http://www.php.net/manual/en/phar.setsignaturealgorithm.php). If it is Phar::OPENSSL - **openSSLPrivateKeyAlias** is required.
- **openSSLPrivateKeyAlias** - Alias to OpenSSL certificate, should be on \\Phar::OPENSSL signature set.
- **stub** - Alias to stub file, if false - will not be set.

Components
----------

[](#components)

Components - php classes for files modifications in phar archives. For example: remove all whitespaces from php code. Components configuration is just like yii Application components, for example:

```
return [
    'modules' => [
        'phar' => [
            'class' => 'index0h\\phar\\Module',
            'components' => [
                'fixer' => [
                    'class' => 'index0h\\phar\\components\\php\\Fixer',
                    'match' => '/.*\.php/'
                ]
            ]
        ]
        ...
    ],
    ...
];
```

### Available components

[](#available-components)

#### Fixer

[](#fixer)

Fixer changes realpath functions in files that doesn't work in phar.

- **match** - List of regexp for files that must be modified.
- **replace** - Array of regexp for \[`from` =&gt; `to`\] for modifications in files.

#### Minimize

[](#minimize)

Removes all whitespaces form php files by php\_strip\_whitespace.

- **match** - List of regexp for files that must be modified.

### Writing own component

[](#writing-own-component)

Simply create class that extends index0h\\phar\\base\\Component and implement processFile method.

For example minimize component:

```
namespace index0h\phar\components\php;

use index0h\phar\base\Component;
use index0h\phar\base\FileEvent;

/**
 * Removes whitespace and comments from php files.
 */
class Minimize extends Component
{
    /**
     * For all php files without suffix Controller (because help command parses comments).
     */
    protected $match = ['/(?'];

    /**
     * Modification of file.
     *
     * @param FileEvent $event Event with file information.
     */
    public function processFile(FileEvent $event)
    {
        file_put_contents($event->realPath, php_strip_whitespace($event->realPath));
    }
}
```

#### FileEvent structure

[](#fileevent-structure)

- realPath - path to temporary file.
- relativePath - path in phar file.

Testing
-------

[](#testing)

#### Run tests from IDE (example for PhpStorm)

[](#run-tests-from-ide-example-for-phpstorm)

- Select Run/Debug Configuration -&gt; Edit Configurations
- Select Add New Configuration -&gt; PHP Script
- Type:
    - File: /path/to/yii2-phar/.test.php
    - Arguments run: run --coverage --html
- OK

#### Run tests from IDE (example for PhpStorm) `inside phar archive`

[](#run-tests-from-ide-example-for-phpstorm-inside-phar-archive)

- Select Run/Debug Configuration -&gt; Edit Configurations
- Select Add New Configuration -&gt; PHP Script
- Type:
    - File: /path/to/yii2-phar/.test.phar.php
    - Arguments run: run --no-exit
- OK

#### Run tests from console

[](#run-tests-from-console)

```
make test-all
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% 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 ~16 days

Total

3

Last Release

4455d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b8a28fe7485e2e7c7e42ebd15c4bd6da4f56dcc307c29f52f9b1d08b656ab78?d=identicon)[index0h](/maintainers/index0h)

---

Top Contributors

[![index0h](https://avatars.githubusercontent.com/u/675070?v=4)](https://github.com/index0h "index0h (45 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

pharmoduleyiibuildyii-moduleyii2-phar

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/index0h-yii2-phar/health.svg)

```
[![Health](https://phpackages.com/badges/index0h-yii2-phar/health.svg)](https://phpackages.com/packages/index0h-yii2-phar)
```

###  Alternatives

[nizsheanez/yii2-asset-converter

Less, Sass, Scss and Phamlp converter for Yii2. No system requires. yii2-composer support, Less autoupdate, customizing of output directory

64167.5k6](/packages/nizsheanez-yii2-asset-converter)[rmrevin/yii2-comments

Comments module for Yii2

5130.8k](/packages/rmrevin-yii2-comments)

PHPackages © 2026

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