PHPackages                             roumen/asset - 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. roumen/asset

Abandoned → [rumenx/php-assets](/?search=rumenx%2Fphp-assets)Library[Utility &amp; Helpers](/categories/utility)

roumen/asset
============

Framework-agnostic PHP package to manage frontend assets in the backend. Integrations for Laravel and Symfony included.

v2.5.5(10y ago)104191.6k165MITPHPPHP &gt;=5.5.9CI passing

Since Apr 11Pushed 2mo ago10 watchersCompare

[ Source](https://github.com/Laravelium/laravel-assets)[ Packagist](https://packagist.org/packages/roumen/asset)[ Docs](https://roumen.it/projects/laravel-assets)[ RSS](/packages/roumen-asset/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (2)Versions (8)Used By (5)

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

49

—

FairBetter than 94% of packages

Maintenance57

Moderate activity, may be stable

Popularity42

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity63

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 ~149 days

Total

5

Last Release

3856d ago

PHP version history (2 changes)v2.3.12PHP &gt;=5.3.0

v2.5.5PHP &gt;=5.5.9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/146950137?v=4)[RumenX](/maintainers/RumenX)[@RumenX](https://github.com/RumenX)

![](https://www.gravatar.com/avatar/39f3431a6b5d6a58a07a85ec345ec83be04f4afc69ee684d9062781c029c8ae7?d=identicon)[Laravelium](/maintainers/Laravelium)

---

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-managementlaravelphpsymfonylaravelmanagerassetsasset

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/roumen-asset/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k9.6k1](/packages/vinkius-labs-laravel-page-speed)[fisharebest/laravel-assets

Asset management for Laravel

208.1k](/packages/fisharebest-laravel-assets)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3614.9k](/packages/linkxtr-laravel-qrcode)[mmanos/laravel-casset

An asset management package for Laravel 4.

102.6k](/packages/mmanos-laravel-casset)

PHPackages © 2026

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