Download the PHP package hollyit/laravel-static-libraries without Composer

On this page you can find all versions of the php package hollyit/laravel-static-libraries. 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-static-libraries

Introduction

(please note that this documentation is a work in progress.)

Static Libraries are a way to corral all your various static assets used on your webpages, such as various stylesheets and javascript libraries. They provide a mechanism to easily include multiple items, without needing to remember dependency or orders.

Static Libraries are registered via an event. This way if you don't require any libraries, then nothing happens and performance is saved. So if you want to register a library, simply add this to the boot() method of your service provider:

The signature of the Library::make is $libraryName, $basePath. The above example is assuming you are developing a package. You can also use libraries in your own app and set the base path to a location in public_path or anywhere else. This package will know how to handle it.

Installation

First, you will need to require this package:

After that, you need to update your blade files to inject the assets. So in the head of your blade file, simply add:

@static_assets_head()

And before the closing tag, add:

@static_assets_footer()

These two directives call a series of other blade templates to assemble the code of all the required libraries. You can feel free to publish the templates to override them, but the defaults should suffice.

Understanding libraries

As you may have noticed above, libraries add asserts, which are the actual javascript or css files/code you wish to add. There are currently 5 types of assets available.

The first three asset types are Css, Js, and JsModule and are file-based assets. You either add them as a relative path to your library's base_path or as a URL (thus allowing for CDN or external files).

The final two asset types are InlineStyle and InlineScript. As the name applies, these are inline-style assets, that will inject the provided code between the appropriate <style> or <script> tags.

On all assets, you can supply attributes to add to the appropriate tags. For example:

will add in a style sheet with the media="print" attribute.

JsModule

This package provides a custom JsModule asset type. Ths signature for this asset type's factory is a little different:

When rendered it will add in the type="module" and name="{$name}" attributes. But JsModules offer much more than that.

A proposed standard for ES Modules is import-map's. You can read about them here. While adaptation isn't that wide yet, this module will inject a shim to provide support to browser's that need it. This shim can be overridden in the static-libraries config file.

When you add JsModules to your library, this package will automatically render an import map for your page. Here's an example of what I mean:

This map was automatically generated from the following libraries:

Dependency Management

Libraries can also manage dependencies. By chaining a ->requires(...libraries) to your library declaration, any time that library is required, it will automatically require and place before it the libraries defines in requires().

Another dependency feature is adding a library when another one is required. For example, say you are using TinyMCE and have another library that provides a plugin for it. Well if you define a library:

Then simply doing a $libraries->require('tinymce') will also include 'tinymce_plugin'. You can also specify if that library should be added before or after the parent library:

Two positioning rules are offered, PositionBefore and PositionAfter.

Asset serving

This package uses a concept of drivers to handle publishing and serving your static assets. It ships with two drivers, but more can be added. The driver can be configured in the static-libraries config file, or by setting STATIC_LIBRARIES_DRIVER in your .env file.

Dev Driver

This is the simplest driver. It serves all your local assets via Laravel.

New in 1.1.0

You can now specify ->withHotFile(...file path...) onto your library. When using the dev driver, if the hotfile is present it will automatically parse and include that. Currently, this is for Laravel Mix only. Vite will be added in the near future.

File Driver

This driver is what's known as a publishable driver. That means it will copy the various files from their location over to your public_path. If the files aren't found there, then it will fall back to utilizing Laravel to serve the files. This driver also integrates cache busting, based on the hash of the static file.

To publish files, simple issue this artisan command:

You can also unpublish libraries with:

An important note here: As more packages utilize static libraries, it can be easy to end up with stale published assets. To prevent that, it is recommended to add the following to the scripts section of your project's composer.json:

That way whenever you update your packages, any libraries that have been modified will publish their files.

Development info

The package offers one other artisan command, static-libraries:info This will list out all the registered libraries, their publishing status and if the published files are out of date or not.

Future Development

I would very much appreciate anyone wanting S3 support to please open a PR and create a driver to handle that. I'm not a big user of S3, but this package will work fine with it and using the fallback rules of S3, should be able to fall back to serving files through laravel if needed.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-static-libraries with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
illuminate/contracts Version ^8.6 || ^9.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 hollyit/laravel-static-libraries contains the following files

Loading the files please wait ....