Download the PHP package rosswintle/laravel-asset-cache without Composer

On this page you can find all versions of the php package rosswintle/laravel-asset-cache. 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 laravel-asset-cache

Laravel Asset Cache

A Laravel package that automates downloading CSS and JS assets from CDNs so that they can be self hosted.

Why shoud I do this? <- Long-read!

Installation

Use the following versions:

Install the package with composer:

Cached assets are stored in and served from the public file storage "disk". You will need to have symlinked your public/storage directory to storage/app/public as per the Laravel docs using:

Be sure to do this in ALL environments: local, staging, and production.

Usage

Blade directive

If you just want a <script> tag for a JavaScript asset then you can use the blade directive

Example

Method call

A more flexible way is to use the static cachedAssetUrl() method of the LaravelAssetCache class, accessible through a facade as follows:

Parameter definitions are the same as for the Blade directive, above.

This is more flexible as you can add your own attributes to the tag that refers to the asset.

You can also use this method for CSS:

What does this do?

Using the Blade directive or cachedAssetUrl method:

What problem does this solve?

There's a FULL explanation on my blog.

It saves you having to manually download assets and include them in your project if you want to host them locally.

There are various reasons why you may want to do this, such as avoiding having your users tracked, to avoid depending on third-party CDNs and there are possible performance benefits too.

I'm also on a mission to ditch npm and build process from simple projects, so this bit of automation seemed useful.

If you dare specify an imprecise version constraint such as just 1.9 you can also get latest releases of dependencies without having to do anything! But all the big CDN's advise against this as it can break your site so use with caution and avoid in production environments!!

Compatibility

This package was built for and tested with Laravel 6.x, but should work on older and newer versions.

Be aware that package auto-discovery only works in Laravel 5.5 and higher. With older versions you will have to add the service provider and alias manually. I'm not providing instructions because you should be running newer Laravel.

Limitations

This is my first public package. All sorts of things could be wrong! Please be gentle.

I've not tested this on huge files, but it works for 73kb of compressed TailwindCSS.

Currently only works with npm packages, and pulls from cdn.jsdelivr.net

Downloads are currently synchronous so if an end user hits a cache operation they will see a slower page load.

Testing

I'm not an expert tester, so I've tested some aspects of the package, but not the use of Cache and Storage.

Feel free to contribute tests if you know how.

Roadmap

Credits


All versions of laravel-asset-cache with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1
laravel/framework Version ^8.0|^9.0
guzzlehttp/guzzle Version ^7.0
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 rosswintle/laravel-asset-cache contains the following files

Loading the files please wait ....