Download the PHP package spekkionu/assetcachebuster without Composer

On this page you can find all versions of the php package spekkionu/assetcachebuster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package assetcachebuster

Build Status Scrutinizer Quality Score Code Coverage

Asset Cache Buster

This package prefixes asset urls with md5 hashes so that changing the hash results in the url for all asset files to change. This forces browsers to download new versions of the asset files before the browser cache is expired.

This is especially useful when using a CDN that sets far future expires headers on files.

It works with any static files like stylesheets, javascript files, and images.

Installation

The 2.x branch is only compatible with Laravel 5.x. If you need Laravel 4.x compatibility use the 1.x branch.

Add spekkionu\assetcachebuster as a requirement with composer:

If you have disabled automatic package discovery you will need to register the service provider with the application. Open up config/app.php and find the providers key.

If you have disabled automatic package discovery you will need to register the facade in order to generate an asset url. You can register the facade via the aliases key of your config/app.php file.

There are other packages that want to register the Asset facade. If this is the case you can change the Asset key to be something else to prevent a collision.

For the asset urls to function the following will need to be added to the apache .htaccess file. Add the following to your .htaccess file before the Laravel rewrite rule:

For Nginx, add the following to your virtual host file

Configuration

In order to generate new hashes to invalidate the cache you must publish the package configuration by running the following artisan command.

This will create a config file at config/assetcachebuster.php Use this file to configure the package.

Set the enabled flag in the config to true in order for asset urls to be prefixed.

Usage

For any asset urls you want to be able to cache you must use the Asset::url($url) facade rather than directly outputting the url. For example if you wanted to link to a stylesheet located at /css/stylesheet.css you would add the following to your view

If you are using a blade template the following will work instead.

Invalidating the Cache

To generate a new hash to invalidate caches and force browsers to download new versions of asset files run the following artisan command.

This will generate a new hash and update the config file. It is important that you do not change the hash line of the config file manually or this command may no longer function. If you must manually update the hash make sure it is a valid md5 hash or exceptions will be thrown when generating a hashed url. A md5 hash is a 32 character string with only the characters 0-9 and a-f.

Using with a CDN

To use with a CDN such as Cloudfront set the cdn key in the config to the cdn url.

Now any asset url will begin with the cdn url.

This will only work with a CDN that supports origin pull as it does not push any asset files to the cdn.

Setting Far Future Expires Headers

In order to actually receive a benefit from the package asset files should be set with far future expires headers.

To do this add the following to your apache .htaccess file.

You might need to configure your cdn to set these headers if you are using one.

For Nginx, add the following to your virtual host file


All versions of assetcachebuster with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/support Version 5.5.* | 5.6.* | 5.7.* | 5.8.* | 6.* | 7.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spekkionu/assetcachebuster contains the following files

Loading the files please wait ....