Download the PHP package nedarta/php-assetopt without Composer

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

php-assetopt

Small, dependency-free PHP utility library that optimizes frontend assets (CSS and JavaScript) without external binaries such as the Java-based YUI Compressor or closure-compiler.

Latest Stable Version Total Downloads Daily Downloads License

Requirements

Installation

Note: composer.phar install is needed to run the tests, GUI or CLI utilities within the repository downloaded from GitHub.

Usage

PHP

Resolving @import at-rules (local relative paths and remote http/https urls) before minifying:

CLI

The CLI allows both the option-style commands used by the original YUI Compressor port, and the positional {from} {to}-style commands used in e.g. Yii2's AssetManager. Use --type js to strip JavaScript, or --type css (the default) to minify CSS:

Output compression result to another file:

Minify JavaScript:

Output minified CSS code to standard output:

YUI-compressor-style commands (the --type flag selects the pipeline, --disable-optimizations is accepted and ignored):

Merge and minify several external CSS files into one file (files are processed in the given order, duplicate @charset rules are removed automatically):

Keep sourcemap comments in the output:

Remove /*! ... */ important comments from the output:

Inline stylesheets pointed to by @import at-rules (local relative paths and remote http/https urls) before minifying — imported stylesheets are resolved recursively, imported files declaring media queries are wrapped in the equivalent @media block:

See the binary help (./vendor/bin/assetopt --help) for all available options.

Framework integration (Yii2 example)

Use the library's CLI as a drop-in replacement for legacy Java-based compressors. The asset bundle configuration itself stays unchanged — you only switch the compressor commands in the application config:

Below the assetManager snippet to put in application config, e.g. config/web.php:

This replaces the typical Java-tool configuration (taken as reference of what the above switch replaces):

Notes for Yii2:

GUI

We've made a simple web based GUI to use the compressor, it's in the gui folder.

GUI features:

How to use the GUI:

Tests

Tests from YUI compressor have been modified to fit this port. Run all tests:

API Reference

__construct ([ bool $raisePhpLimits ])

Creates a new minifier instance.

run (string $css)

Takes a CSS string of code to be minified, returning the compressed CSS code if everything is OK; throwing an Exception if the code could not be minified.

keepSourceMapComment (bool $keepSourceMap)

Keeps the sourcemap special comment (/*# sourceMappingURL=... */) after the end of the minification.

removeImportantComments (bool $removeImportantComments)

Removes /*! ... */ special comments — typically license headers — from the minified output.

setLinebreakPosition (int $position)

Better readability of minified CSS could be achieved splitting the output after a specific position, e.g. a column value around 500 characters.

setMaxExecutionTime (int $seconds)

Sets the max PHP execution time allowed to minify.

setMemoryLimit (mixed $limit)

Raised PHP memory limits on minification.

setPcreBacktrackLimit (int $limit)

Raised PCRE backtrack limits on minification.

setPcreRecursionLimit (int $limit)

Raised PCRE recursion limits on minification.

Credits and provenance

This package is based on the following building blocks — big thanks to the original authors:

The compressor implementation remains faithful to the original YUI compressor behavior, with the port optionally inlining @import rules, wiring JavaScript support, and dropping obsolete workarounds for legacy PHP versions.

Changelog

v1.0.0

First release of this package.

History

For project history prior to this version, see the legacy YUI-CSS-compressor-PHP-port repositories (upstream original port by Tobal Martín, and the interim fork nedarta/cssmin).


All versions of php-assetopt with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-pcre Version *
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 nedarta/php-assetopt contains the following files

Loading the files please wait ...