PHPackages                             rumenx/php-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. rumenx/php-assets

ActiveLibrary

rumenx/php-assets
=================

Framework-agnostic PHP package to manage frontend assets in the backend. Works with plain PHP, Laravel, Symfony, and any PHP framework.

v1.0.2(7mo ago)1042.0k—6.3%16MITPHPPHP ^8.2CI passing

Since Feb 10Pushed 1mo ago10 watchersCompare

[ Source](https://github.com/RumenDamyanov/php-assets)[ Packagist](https://packagist.org/packages/rumenx/php-assets)[ GitHub Sponsors](https://github.com/sponsors/RumenDamyanov)[ RSS](/packages/rumenx-php-assets/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (6)Used By (0)

rumenx/php-assets
=================

[](#rumenxphp-assets)

[![CI](https://github.com/RumenDamyanov/php-assets/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/RumenDamyanov/php-assets/actions/workflows/ci.yml)[![PHPStan](https://github.com/RumenDamyanov/php-assets/actions/workflows/phpstan.yml/badge.svg?branch=master)](https://github.com/RumenDamyanov/php-assets/actions/workflows/phpstan.yml)[![codecov](https://camo.githubusercontent.com/ac3fd882cb7e28304748c2224da97912f0de4f58aefaec8e3ec31800f3ec065e/68747470733a2f2f636f6465636f762e696f2f67682f52756d656e44616d79616e6f762f7068702d6173736574732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/RumenDamyanov/php-assets)

Framework-agnostic PHP package to manage frontend assets in the backend. Works with plain PHP, Laravel, and Symfony with no special configuration required.

Features
--------

[](#features)

- Add, order, and output CSS, LESS, and JS assets from PHP
- Cache busting (file or function based)
- Environment and domain support
- Works directly with Laravel, Symfony, and any PHP framework
- No special configuration or adapters required
- 100% test coverage, static analysis, and CI

---

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

[](#installation)

```
composer require rumenx/php-assets
```

---

Usage Examples
--------------

[](#usage-examples)

### Plain PHP

[](#plain-php)

```
use Rumenx\Assets\Asset;

// Add assets
Asset::add('style.css');
Asset::add('theme.less');
Asset::add('app.js');
Asset::add(['extra.js', 'extra2.js'], 'footer');

// Add inline style or script
Asset::addStyle('body { background: #fafafa; }');
Asset::addScript('console.log("Hello!");');

// Output in your template
Asset::css();      //
Asset::less();     //
Asset::js();       //
Asset::styles();   // ...
Asset::scripts();  // ...

// Use cachebuster (file-based)
Asset::setCachebuster(__DIR__.'/cache.json');

// Use cachebuster (function-based)
Asset::setCacheBusterGeneratorFunction(function($file) {
    return md5($file);
});

// Custom domain or prefix
Asset::setDomain('https://cdn.example.com/');
Asset::setPrefix('X-');
```

---

Design Philosophy
-----------------

[](#design-philosophy)

This package follows a **simple, framework-agnostic approach** by design. Unlike some asset management packages that require service providers, adapters, or complex integrations, php-assets works out-of-the-box with any PHP framework or plain PHP project.

**Why no special adapters or service providers?**

- **Simplicity**: Just use `Asset::add()` - no magic, no hidden complexity
- **Universal compatibility**: Works with Laravel, Symfony, CodeIgniter, or any PHP framework
- **Easy debugging**: No framework-specific layers to troubleshoot
- **Minimal maintenance**: No need to maintain separate adapters for different frameworks
- **Standard PHP**: Uses only basic PHP features (static methods, arrays, string manipulation)

This approach makes the package more reliable, easier to understand, and ensures it will continue working across different framework versions without requiring updates.

---

### Laravel Integration

[](#laravel-integration)

```
use Rumenx\Assets\Asset;

// In your controller or anywhere in your Laravel app
Asset::add('main.css');
Asset::add('main.js');

// In your Blade template
{!! Asset::css() !!}
{!! Asset::js() !!}
```

---

### Symfony Integration

[](#symfony-integration)

```
use Rumenx\Assets\Asset;

// In your controller
Asset::add('main.css');
Asset::add('main.js');

// In a Twig template
{{ asset_css()|raw }}
{{ asset_js()|raw }}
```

Or create a simple Twig extension:

```
// src/Twig/AssetExtension.php
use Rumenx\Assets\Asset;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class AssetExtension extends AbstractExtension
{
    public function getFunctions(): array
    {
        return [
            new TwigFunction('asset_css', fn() => Asset::css()),
            new TwigFunction('asset_js', fn() => Asset::js()),
        ];
    }
}
```

---

Advanced Usage
--------------

[](#advanced-usage)

- **Add assets to specific locations:**
    - `Asset::add('file.js', 'header');` // Add JS to header
    - `Asset::addFirst('file.js');` // Add as first asset
    - `Asset::addBefore('new.js', 'old.js');` // Insert before another
    - `Asset::addAfter('new.js', 'old.js');` // Insert after another
- **Environment detection:**
    - `Asset::$envResolver = fn() => app()->environment();`
- **Custom URL generator:**
    - `Asset::$urlGenerator = fn($file, $secure) => asset($file, $secure);`

---

Testing
-------

[](#testing)

```
composer test
```

Static Analysis
---------------

[](#static-analysis)

```
composer analyze
```

Development &amp; Testing
-------------------------

[](#development--testing)

### Running Tests

[](#running-tests)

```
composer test
```

### Running Static Analysis

[](#running-static-analysis)

```
composer analyze
```

### CI/CD

[](#cicd)

- GitHub Actions for tests, static analysis, and Codecov coverage reporting.

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

[](#contributing)

We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on how to get started.

Security
--------

[](#security)

If you discover a security vulnerability, please review our [Security Policy](SECURITY.md) for information on how to report it responsibly.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes to this project.

Funding
-------

[](#funding)

If you find this project useful, consider [supporting its development](FUNDING.yml).

License
-------

[](#license)

This project is licensed under the [MIT License](LICENSE.md).

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance78

Regular maintenance activity

Popularity37

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 70.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 ~52 days

Total

3

Last Release

236d ago

PHP version history (2 changes)v1.0.0-betaPHP &gt;=8.3

v1.0.2PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/48dce3e6200e787e75a4a14e0d31738d112261fe0877f15f74d3fb2c2a626229?d=identicon)[RumenX](/maintainers/RumenX)

---

Top Contributors

[![RumenDamyanov](https://avatars.githubusercontent.com/u/1458253?v=4)](https://github.com/RumenDamyanov "RumenDamyanov (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")

---

Tags

assetsassets-managementlaravelphpsymfonyphpsymfonylaravelmanagerassetsfrontendframework agnostic

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rumenx-php-assets/health.svg)

```
[![Health](https://phpackages.com/badges/rumenx-php-assets/health.svg)](https://phpackages.com/packages/rumenx-php-assets)
```

###  Alternatives

[rumenx/php-sitemap

Framework-agnostic Sitemap generator for PHP, Laravel, and Symfony.

1.3k15.1k1](/packages/rumenx-php-sitemap)[dragon-code/support

Support package is a collection of helpers and tools for any project.

238.7M101](/packages/dragon-code-support)[tomatophp/filament-media-manager

Manage your media files using spatie media library with easy to use GUI for FilamentPHP

14543.9k3](/packages/tomatophp-filament-media-manager)[sockeon/sockeon

Framework-agnostic PHP WebSocket and HTTP server library with attribute-based routing and support for namespaces and rooms.

291.3k2](/packages/sockeon-sockeon)[hafael/azure-mailer-driver

Supercharge your Laravel or Symfony app with Microsoft Azure Communication Services (ACS)! Effortlessly add email, chat, voice, video, and telephony-over-IP for next-level communication. 🚀

14109.2k](/packages/hafael-azure-mailer-driver)[rumenx/php-seo

AI-powered, framework-agnostic PHP package for automated SEO optimization. Intelligently generates meta tags, titles, descriptions, and alt texts using configurable AI providers or manual patterns.

102.0k](/packages/rumenx-php-seo)

PHPackages © 2026

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