PHPackages                             heimrichhannot/contao-encore-contracts - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. heimrichhannot/contao-encore-contracts

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

heimrichhannot/contao-encore-contracts
======================================

A set of abstractions needed for encore bundle preparation.

1.1.0(8mo ago)027.4k↓28.3%20LGPL-3.0-or-laterPHPPHP ^7.4 || ^8.0

Since Oct 4Pushed 8mo ago5 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-encore-contracts)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-encore-contracts)[ Docs](https://github.com/heimrichhannot/contao-encore-contracts)[ RSS](/packages/heimrichhannot-contao-encore-contracts/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (6)Used By (20)

Contao Encore Contracts
=======================

[](#contao-encore-contracts)

This package contains abstractions to add loose [Encore bundle](https://github.com/heimrichhannot/contao-encore-bundle) support.

Usage
-----

[](#usage)

### Register entrypoints

[](#register-entrypoints)

To register encore entrypoints create an EncoreExtension class implementing `EncoreExtensionInterface`.

```
namespace HeimrichHannot\ExampleBundle\Asset;

use HeimrichHannot\EncoreContracts\EncoreEntry;
use HeimrichHannot\EncoreContracts\EncoreExtensionInterface;
use HeimrichHannot\ExampleBundle\HeimrichHannotExampleBundle;

class EncoreExtension implements EncoreExtensionInterface
{
    public function getBundle(): string
    {
        // Return the bundle class
        return HeimrichHannotExampleBundle::class;
    }

    public function getEntries(): array
    {
        // Return the bundle entries
        return [
            EncoreEntry::create('main-theme', 'assets/main/js/main-theme.js')
                ->setRequiresCss(true)
                ->setIsHeadScript(false),
            EncoreEntry::create('one-pager', 'assets/one-pager/js/one-pager.js')
                ->setRequiresCss(true),
            EncoreEntry::create('custom-head-js', 'assets/main/js/head.js')
                ->setIsHeadScript(true)
                // Define entries that will be removed from the global asset array
                ->addJsEntryToRemoveFromGlobals('colorbox')
                ->addCssEntryToRemoveFromGlobals('css-to-replace'),
        ];
    }
}
```

### Add entrypoints for current page

[](#add-entrypoints-for-current-page)

To add entrypoints (must be registered beforehand) from your code, you can use the `PageAssetsTrait`. It checks if encore bundle is installed and add the entry, if this is the case. Otherwise, it adds the fallback assets to the contao global asset array.

Make your class implement `ServiceSubscriberInterface` and use `PageAssetsTrait` (it already implements the needed methods for the ServiceSubscriberInterface). Afterwards just call `$this->addPageEntrypoint(string $name, array $fallbackAssets = [])`.

```
use HeimrichHannot\EncoreContracts\PageAssetsTrait;
use Symfony\Contracts\Service\ServiceSubscriberInterface;

class FrontendController implements ServiceSubscriberInterface
{
    use PageAssetsTrait;

    public function __invoke()
    {
        $this->addPageEntrypoint(
            // Encore entry point name
            'contao-example-bundle',
             // Optional: define fallback assets to use if encore bundle is not installed
            [
                'TL_CSS' => ['main-theme' => 'assets/main/dist/main-theme.min.css|static'],
                'TL_JAVASCRIPT' => [
                    'main-theme' => 'assets/main/dist/main-theme.min.js|static',
                    'some-dependency' => 'assets/some-dependency/some-dependency.min.js|static',
                ],
            ]
        );
    }
}
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance60

Regular maintenance activity

Popularity27

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.8% 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 ~355 days

Total

4

Last Release

256d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/28ad3224d8727b622ebd229840eea6b9dbcb83eb0bd609e6ce65b614830ff538?d=identicon)[digitales@heimrich-hannot.de](/maintainers/digitales@heimrich-hannot.de)

---

Top Contributors

[![koertho](https://avatars.githubusercontent.com/u/12064642?v=4)](https://github.com/koertho "koertho (10 commits)")[![ericges](https://avatars.githubusercontent.com/u/25957923?v=4)](https://github.com/ericges "ericges (6 commits)")[![heimrich-hannot](https://avatars.githubusercontent.com/u/37208441?v=4)](https://github.com/heimrich-hannot "heimrich-hannot (1 commits)")

### Embed Badge

![Health badge](/badges/heimrichhannot-contao-encore-contracts/health.svg)

```
[![Health](https://phpackages.com/badges/heimrichhannot-contao-encore-contracts/health.svg)](https://phpackages.com/packages/heimrichhannot-contao-encore-contracts)
```

###  Alternatives

[league/container

A fast and intuitive dependency injection container.

86787.8M343](/packages/league-container)[stella-maris/clock

A pre-release of the proposed PSR-20 Clock-Interface

7947.5M2](/packages/stella-maris-clock)[wptrt/wpthemereview

PHP\_CodeSniffer rules (sniffs) to verify theme compliance with the rules for theme hosting on wordpress.org

217736.5k29](/packages/wptrt-wpthemereview)[inpsyde/modularity

Modular PSR-11 implementation for WordPress plugins, themes or libraries.

54383.3k3](/packages/inpsyde-modularity)[php-standard-library/phpstan-extension

PHPStan PSL extension

201.2M13](/packages/php-standard-library-phpstan-extension)[elie29/zend-phpdi-config

PSR-11 PHP-DI autowire container configurator for Laminas, Mezzio, ZF2, ZF3 and Zend Expressive applications

20238.6k7](/packages/elie29-zend-phpdi-config)

PHPackages © 2026

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