PHPackages                             plesk/yii2-static-assets - 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. plesk/yii2-static-assets

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

plesk/yii2-static-assets
========================

Generate static assets

v1.0.1-p1(6y ago)120MITPHPPHP &gt;=7.0

Since Nov 2Pushed 6y agoCompare

[ Source](https://github.com/plesk/yii2-static-assets)[ Packagist](https://packagist.org/packages/plesk/yii2-static-assets)[ RSS](/packages/plesk-yii2-static-assets/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (36)Used By (0)

yii2-static-assets
==================

[](#yii2-static-assets)

Prevent publishing of assets at production time without changing your application.

This fork removes docker-related stuff (just like the work of the ItsReddi: , just more recent) and adds CLI command parameters. Original project of the SAM-IT's is available here: .

Original project description below.

Motivation
==========

[](#motivation)

Nowadays docker is getting more and more attention and PHP applications are seeing different deployment scenarios. Where a few years ago if you split your nodes up at all you'd only split up the database server and the webserver that runs PHP as module or more recently via PHP-FPM, nowadays you want to split everything up.

Challenges
==========

[](#challenges)

Having your webserver, for example nginx, running on a different server than PHP-FPM comes with several challenges, pros and cons:

1. PHP can't write files and create publicly accessible URLs for them
2. Cannot use local session storage
3. File uploads that need to be publicly accessible need to be published to the webserver.
4. File uploads that need to be protected have to accessible by all PHP nodes (so some kind of central storage is needed).

Solution
========

[](#solution)

This extension will provide a solution for number 1 when it comes to Yii assets. The asset management system is nice when pushing changed assets directly to a server, it doesn't really work well in distributed environments though, so we need another approach.

This extension provides:

- A console command that will scan your source code and vendor directory and will extract all your assets.
- An AssetManager for use in production that will generate URLs for assets without checking for touching storage.

The workflow then becomes a bit different. During development the asset manager will act like a normal asset manager, publishing assets to the asset directory. When using docker-compose for the test environment you would mount the same host directory to the asset folder in the PHP container and in the webserver container.

During deployment the assetmanager simply returns URLs for assets on the assumption that they exist. Before deploying a new version of your app, you will rebuild your webserver container. This extension provides a console command that will publish all your assets to a directory of your choosing, this can then be used as part of the docker build context.

To publish your assets run the following command:

```
yii staticAssets/asset/publish build12345

```

This will create the directory `build12345` inside your runtime directory and publish all assets there.

Asset discovery / publishing
============================

[](#asset-discovery--publishing)

Assets are discovered by recursively iterating over all folders and files. Each file that ends with `.php` is then processed:

- The namespace is extracted via regular expression matching.
- The class name is extracted via regular expression matching.
- We use reflection to check if the class is an instance of `yii\web\AssetBundle` and if so it is published.

Container building
==================

[](#container-building)

To build an nignx container for server your application use this:

```
yii staticAssets/asset/build-container

```

You can configure the module to set some default values.

Configuration
=============

[](#configuration)

For simple configuration use the `ReadOnlyAssetManager` in your application during production and development. This asset manager will use a simpler "hash" function that keeps directory structure readable. It supports `$assetDevelopmentMode` which allows for local asset development in a dockerized environment.

Asset development
=================

[](#asset-development)

The assumption is that you use docker-compose for local development, in which case you need to define a volume where assets are stored so that they are available in both the webserver as well as the phpfpm container:

```
volumes:
  assets:
nginx:
    image: [name of your nginx container, built by this module]
    environment:
      PHPFPM: "phpfpm:9000"
      RESOLVER: "127.0.0.11"
    ports:
      - "12346:80" # Port where the application will be available
    depends_on:
      - phpfpm
    volumes:
    # Defines the named volume as read-only for the webserver.
    # Note the dev-assets, which allows to easily identify development
    # mode while using browsers' developer tools.
      - type: volume
        source: assets
        target: /www/dev-assets
        read_only: true
        volume:
          nocopy: true
  phpfpm:
    dns: 8.8.4.4
    image: [ name of your PHPFPM docker image ]
    environment:
      DB_USER: root
      DB_NAME: test
      DB_PASS: secret
      DB_HOST: mysql
    depends_on:
      - mysql
    volumes:
      # The source code is loaded into PHPFPM for local development,
      # for production it should be baked into the image.
      - .:/project:ro
      # The asset volume, note the location which is where the ReadOnlyAssetManager
      # will publish assets when in development mode.
      - type: volume
        source: assets
        target: /tmp/assets

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 81.6% 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 ~28 days

Recently: every ~153 days

Total

33

Last Release

2223d ago

Major Versions

v0.9.1 → v1.0.02019-02-28

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/187856?v=4)[Alexey Yuzhakov](/maintainers/sibprogrammer)[@sibprogrammer](https://github.com/sibprogrammer)

![](https://www.gravatar.com/avatar/1916e8e87254ef106fbaefa67de07d17fb78d0295fdf458b9256543da249b815?d=identicon)[dshiryaev-plesk](/maintainers/dshiryaev-plesk)

---

Top Contributors

[![SamMousa](https://avatars.githubusercontent.com/u/547021?v=4)](https://github.com/SamMousa "SamMousa (62 commits)")[![ham3r](https://avatars.githubusercontent.com/u/16233395?v=4)](https://github.com/ham3r "ham3r (12 commits)")[![dshiryaev-plesk](https://avatars.githubusercontent.com/u/19424413?v=4)](https://github.com/dshiryaev-plesk "dshiryaev-plesk (2 commits)")

###  Code Quality

TestsCodeception

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/plesk-yii2-static-assets/health.svg)

```
[![Health](https://phpackages.com/badges/plesk-yii2-static-assets/health.svg)](https://phpackages.com/packages/plesk-yii2-static-assets)
```

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

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