PHPackages                             evista/compress - 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. evista/compress

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

evista/compress
===============

Composer package manager integration for WordPress

v1.0(10y ago)017[2 issues](https://github.com/balintsera/evista-composer-wordpress/issues)MITPHPPHP &gt;=5.5.0

Since Oct 23Pushed 9y ago2 watchersCompare

[ Source](https://github.com/balintsera/evista-composer-wordpress)[ Packagist](https://packagist.org/packages/evista/compress)[ RSS](/packages/evista-compress/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

ComPress
========

[](#compress)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5252acff2516c6bba4baf16ed6e24627231bba603f97c4c8472ea3170cbbf0c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c65616775652f6576697374612f636c65616e5f636f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/evista/clean_code)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/6ddd4162de2547ca9f461e8412be7fae0eb942b9cc45a656b6a0f6312345aa08/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7468657068706c65616775652f6576697374612f636c65616e5f636f64652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/thephpleague/evista/clean_code)[![Coverage Status](https://camo.githubusercontent.com/729ee73228c3d60abb4346530bfaad7bd1f12336dcb6dfc68428f1621e84810e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7468657068706c65616775652f6576697374612f636c65616e5f636f64652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/evista/clean_code/code-structure)[![Quality Score](https://camo.githubusercontent.com/10e6f16fda9681b1e3253e75aa66f39238ee570382c8ccff108778e5a62fcb14/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7468657068706c65616775652f6576697374612f636c65616e5f636f64652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/evista/clean_code)[![Total Downloads](https://camo.githubusercontent.com/84acfc5206915747cd1bc00f0fe77bad75b9a15c5f5d23d14db83e807d2ffb95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616775652f6576697374612f636c65616e5f636f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/evista/clean_code)

ComPress is a Wordpress plugin that helps to use composer with a lazy loader service container (dependency injector).

Install
-------

[](#install)

Usage
-----

[](#usage)

```
echo $container->get('twig.templating')->render('index.twig.html', ['hehh' => 'Yeah!']);
```

Documentation
-------------

[](#documentation)

ComPress plugin makes the marvellous Composer accessible in any WordPress project. If you never heard about it, Composer is a PHP package manager with a very good dependency resolver that makes using of third party libraries a breeze.

Composer transformed the PHP ecosystem recently so you should probably learn it. If you want to use the latest Twig templating engine in your WordPress plugins or themes you only have to

1. run composer require twig/twig in the module’s root dir
2. add the new package to the lazy loader service container’s setup

Afterwards the Twig rendering engine will be accessible from anywhere this way:

```
echo $container->get('twig.templating')->render('index.twig.html', ['hehh' => 'Yeah!']);
```

### How to add a package to the container

[](#how-to-add-a-package-to-the-container)

Every package has a different way of initializing, the container helps collect them under a unified API -- and besides it helps decoupling your code (decoupling makes your code more maintanable and solid)

Twig’s documentation says this is the way you can instantiates Twig after installing it:

```
$loader = new Twig_Loader_Filesystem('/path/to/templates');
$twig = new Twig_Environment($loader, array(
    'cache' => '/path/to/compilation_cache',
));

echo $twig->render('index.html', array('name' => 'Fabien'));
```

So the container needs to instantiate two classes, the Twig\_Loader\_Filesystem and using it as an argument the Twig\_Environment class, that can be used to rendering directly. The container can solve this dependency easily if we define two services, and use the first as an argument of the second:

```
//wp-content/plugins/evista-composer/Composer.php

/**
     * Add service definitions here:
     *
     */
  public function setUpServices(){
      $this->services = [
          'twig.loader' =>[
              'class' => '\Twig_Loader_Filesystem',
              'arguments' => [__DIR__.'/views']
          ],
          'twig.templating' => [
              'class' => '\Twig_Environment',
              'arguments' => ['@twig.loader']
          ],
      ];
    }
```

The Composer::services variable holds all the needed informations. Every one of them requires a unique name, that will identify them throughout WordPress. These names will be the keys of the services array, and the most important properties of the services in an array are the values.

In the above example, ‘twig.templating’ is the name, this is how it can be requested from the container:

```
$templating = $container->get('twig.templating');
$page = $templating->render('index.twig.html', ['hehh' => 'Yeah!']);
```

In the configuration array above there are two important key value pairs: class and arguments.

The first tells the container which class should it use to instantiate the service (with namespaces), and second tells what argument to use in what order. So far strings, flat (one level) arrays and other services are supported as argument.

```
public function setUpServices(){
      $this->services = [
          'sample.service' =>[
              'class' => '\SampleService',
              'arguments' => ['string', '@other.service', ['first'=>'1', "second" => '2']]
          ],
          // ..
      ];
    }
```

And this is it. After modifying Composer you are ready to use your new package installed via composer.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Balint Sera](https://github.com/serabalint)
- [Evista Creative Agency](http://evista-agency.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 97.4% 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

Unknown

Total

1

Last Release

3903d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ab3f9b98b8874849b833ccc3b0dd415d8b116654b319d17e687c218e9021e87?d=identicon)[balintsera](/maintainers/balintsera)

---

Top Contributors

[![balintsera](https://avatars.githubusercontent.com/u/8377085?v=4)](https://github.com/balintsera "balintsera (38 commits)")[![succli](https://avatars.githubusercontent.com/u/9085766?v=4)](https://github.com/succli "succli (1 commits)")

---

Tags

phpcomposerdependency managerevista

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/evista-compress/health.svg)

```
[![Health](https://phpackages.com/badges/evista-compress/health.svg)](https://phpackages.com/packages/evista-compress)
```

###  Alternatives

[php-collective/dto

Framework-agnostic Data Transfer Object library with code generation

2812.2k6](/packages/php-collective-dto)

PHPackages © 2026

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