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

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hkt/psr7-asset
==============

Managing assets via PSR-7

0.5.0(7y ago)41.1k2[2 issues](https://github.com/harikt/psr7-asset/issues)MITPHPPHP ^5.6 || ^7.0

Since Aug 6Pushed 7y ago2 watchersCompare

[ Source](https://github.com/harikt/psr7-asset)[ Packagist](https://packagist.org/packages/hkt/psr7-asset)[ RSS](/packages/hkt-psr7-asset/feed)WikiDiscussions master Synced today

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

Psr7Asset
=========

[](#psr7asset)

Asset management for PHP. This package is a fork of [Aura.Asset\_Bundle](https://github.com/friendsofaura/Aura.Asset_Bundle).

Foreword
--------

[](#foreword)

### Requirements

[](#requirements)

- [PSR-7 implementation](https://packagist.org/providers/psr/http-message-implementation).
- [PSR-15 implementation](https://packagist.org/packages/psr/http-server-middleware)
- [PSR-17 implementation](https://packagist.org/packages/psr/http-factory)

### Installation

[](#installation)

```
composer require hkt/psr7-asset http-interop/http-factory-diactoros
```

> You can use any psr-17 libraries.

### Tests

[](#tests)

[![Build Status](https://camo.githubusercontent.com/433b129ac83b5ffb44dfc6c0d3779b1bdda894aee9f215661eef7ded851db07f/68747470733a2f2f7472617669732d63692e6f72672f686172696b742f707372372d61737365742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/harikt/psr7-asset)

```
composer install
vendor/bin/phpunit
```

or you may use;

```
composer install
composer check
```

### PSR Compliance

[](#psr-compliance)

This attempts to comply with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md), [PSR-7](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md), [PSR-15](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-15-request-handlers.md) and [PSR-17](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-17-http-factory.md). If you notice compliance oversights, please send a patch via pull request.

Structure of Package
--------------------

[](#structure-of-package)

Assume you have a `Vendor.Package`. Your assets can be any where. Consider it is in the `public` folder. The folder names `css`, `images`, `js` can be according to your preffered name.

```
├── src
│   ├── Cli
│   └── Web
├── tests
└── public
    ├── css
    │   └── some.css
    ├── images
    │   ├── another.jpg
    │   └── some.png
    └── js
        └── hello.js
```

Assuming you have the same structure, now in your template you can point to `/asset/vendor/package/css/some.css`, `/asset/vendor/package/js/hello.js`, `/asset/vendor/package/images/another.jpg`.

Routing
-------

[](#routing)

The library can be used with any framework. So it makes use of `preg_match` under the hood. The default regular expression is `/\/asset\/([a-zA-Z0-9-_]+)\/([a-zA-Z0-9-_]+)\/(.*)/` .

You can modify the regular expression when intantiating the `Router` object which is passed as 3rd argument to `AssetAction`.

```
