Download the PHP package odan/twig-assets without Composer

On this page you can find all versions of the php package odan/twig-assets. 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 twig-assets

Twig Assets Extension

Caching and compression for Twig assets (JavaScript and CSS), inspired by Symfony Web Assets.

Latest Version on Packagist Build Status Code Coverage Quality Score Total Downloads

Installation

Requirements

Configuration

Integration

Register the Twig Extension

Slim 4 Framework

Requirements

Run:

Add these settings:

Add a DI container definition.

This examples uses PHP-DI

Add the TwigMiddleware. In this case we pass the full class name Twig::class as the second parameter, because the container entry is defined with the same name.

Add a route, e.g. in confg/routes.php:

Create a action class, e.g. src/Action/HomeAction.php:

The (pseudo) content of templates/home/home.twig:

Read more: Usage

Slim 3 Framework

Requirements

In your dependencies.php or wherever you add your Service Factories:

Usage

Custom template functions

This Twig extension exposes a custom assets() function to your Twig templates. You can use this function to generate complete URLs to any Slim application assets.

Parameters

Name Type Default Required Description
files array [] yes All assets to be delivered to the browser. Namespaced Twig Paths (@mypath/) are also supported.
inline bool false no Defines whether the browser downloads the assets inline or via URL.
minify bool true no Specifies whether JS/CSS compression is enabled or disabled.
name string file no Defines the output file name within the URL.
nonce string no The CSP (content security policy) nonce (per request)

Template

Output cached and minified CSS content

Output cached and minified CSS content inline:

Output multiple CSS assets into a single .css file:

Output cached and minified JavaScript content

Output multiple JavaScript assets into a single .js file:

Output page specific assets

Content of file: layout.twig

Content of home.twig:

Add custom attributes to the html element

WARNING: you can override ANY attribute including i.e. href. Be careful here as it can cause unwanted results.

Configure a base path

You should inform the browser where to find the web assets with a base href in your layout template.

Slim Twig example:

Clearing the cache

Clearing the internal cache

Clearing the public cache

Testing

Similar libraries

License

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


All versions of twig-assets with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.1
symfony/cache Version ^4.2.12 || ^5 || ^6
tubalmartin/cssmin Version ^4.1
mrclay/jsmin-php Version ^2.4
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 odan/twig-assets contains the following files

Loading the files please wait ....