PHPackages                             bootpress/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. [Image &amp; Media](/categories/media)
4. /
5. bootpress/asset

ActiveLibrary[Image &amp; Media](/categories/media)

bootpress/asset
===============

Caches and delivers assets of every sort, from any location, with hands-off versioning. Manipulates images on-the-fly. Minifies and combines (on-demand) css and javascript files.

v1.1.1(1y ago)01.0k↓88.9%12MITPHPPHP &gt;=5.4

Since Sep 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Kylob/Asset)[ Packagist](https://packagist.org/packages/bootpress/asset)[ Docs](https://www.bootpress.org/components/asset.html)[ RSS](/packages/bootpress-asset/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (9)Versions (6)Used By (2)

use BootPress\\Asset\\Component as Asset;
=========================================

[](#use-bootpressassetcomponent-as-asset)

[![Packagist](https://camo.githubusercontent.com/bb89d49ae588e07e5a968c267e4447da8d7eaa9443851c5a39d53062d746a132/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626f6f7470726573732f61737365742e7376673f7374796c653d666c61742d737175617265266c6162656c3d5061636b6167697374)](https://packagist.org/packages/bootpress/asset)[![License MIT](https://camo.githubusercontent.com/a7e65aee57b11d28e4caff8b945729a66be0bb663f7f93bd24c5aa65699f148e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![HHVM Tested](https://camo.githubusercontent.com/3422fab0fbdb2e50d74ced25d6df3e7e1be8b373f48c708a785f247a503409d1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4848564d2d5465737465642d3838393262662e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Kylob/Asset)[![PHP 7 Supported](https://camo.githubusercontent.com/7dae9186d16bac6b5d5cee34d3bec4400516657b575bc1c784125d70a6871126/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850253230372d537570706f727465642d3838393262662e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Kylob/Asset)[![Build Status](https://camo.githubusercontent.com/677ba435e0d308c83d02a3da7b77c06ef5b926acf0204eff9b516a020a2eba78/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4b796c6f622f41737365742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Kylob/Asset)[![Code Climate](https://camo.githubusercontent.com/dc7dac327d4dd52ae610e47d3c8a68771ae6c1dd30311431a95c3ff34a0b7d1d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f4b796c6f622f41737365742e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/Kylob/Asset)[![Test Coverage](https://camo.githubusercontent.com/c2a0f9b10660e80f7a738ac775814ec7c8cfd230cabb242a3166c56cf11d9da8/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f6769746875622f4b796c6f622f41737365742e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/Kylob/Asset/coverage)

Asset::cached() is a one-stop method for all of your asset caching needs. This should be the first thing that you call. It checks to see if the page is looking for a cached asset. If it is, then it will return a response that you can `$page->send()`. If not, then just continue on your merry way. When you `$page->display()` your html, it will look for all of your assets, and convert them to cached urls.

- If an asset is found we give it a unique (5 character) id that then becomes the "folder", and we add the `basename()` to the end for reference / seo sakes.
    -  will become  where 'bootstrap.css' means nothing, and ..... is the actual asset location.
    - 60 alphanumeric characters (no 0's) ^ 5 (character length) gives 777,600,000 possible combinations.
- If a #fragment is located immediately after the asset, we'll remove the fragment and ...
    - If it is a .css or .js file then we will combine them together so that  will become  and we'll minify and serve the /page/dir/bootstrap.css, /page/default.css, and /page/dir/user/custom.css files all at once.
    - Otherwise we'll replace the name with it ie.  will become
- If you add a query string to images, we'll remove and save it with the filename ie.  will become  only ..... will be different from the previous example, and the image.jpg's width will be 150 pixels.
    - To see all of the options here, check out the [Glide Quick Reference](http://glide.thephpleague.com/1.0/api/quick-reference/) guide.
- The `filemtime()` is saved so that when an asset changes, we can give it a new unique filename that the browser will then come looking for and cache all over again.
    - This allows us to tell browsers to never come looking for the asset again, because it will never change.
    - There is no better way to make your pages load any faster than this.

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

[](#installation)

Add the following to your `composer.json` file.

```
{
    "require ": {
        "bootpress/asset": "^1.0"
    }
}
```

Example Usage
-------------

[](#example-usage)

```
