Download the PHP package mikehaertl/packagecompressor without Composer

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

PackageCompressor

A Javascript/CSS compressor based on Yii's package system.

Requirements

Features

You probably wonder, why yet another compression extension for Yii? The key difference is, that none of the existing solutions uses Yii's integrated package system for clientscripts. With this extension you can organize all your CSS and Javascript in packages and even define dependencies among them. This may not be very useful for smaller sites (even though you still can use the compressor there, too). But it proved to be extremely helpful when you have to deal with many Javascript files and want to cluster them into a couple of minified package files.

Note: You can even include Yii's core scripts in a package. Unfortunately some Zii widgets like CListView and CGridView still don't use the package system packages. But this will hopefully be fixed in Yii 1.1.15.

Basic example

Packages are set up in your config file. Javascript and CSS packages must be separate. Here's an example:

With the packages defined above you can now for example register the forum packages in the forum section of your site:

Yii::app()->clientScript->registerPackage('forum-js');
Yii::app()->clientScript->registerPackage('forum-css');

Your users will receive single js and CSS files until you reset a package with

./yiic packages reset

How does it work?

Whenever a package is registered through registerPackage() a single compressed file is served to the user. If there is no compressed file yet, all files from the package get combined and compressed, then this single file is published by the asset manager. The extension uses the application state (which gets cached automatically) to store information about a compressed package. So after the initial delay during compression all subsequent requests will get the compressed file delivered lightning fast.

There's also a command line tool to create the compressed file for a package manually, e.g. at deployment time and to reset a package.

The compressed file name will contain a hash to make sure that no visitor ever gets and outdated version of a compressed package.

Installation

Extract the package in protected/extensions into a directory called packagecompressor (remove the -x.y.z suffix). Then configure the component to replace Yii's CClientScript component:

protected/config/main.php

If you want to user the command-line utility, you should make the bundled command available in your console configuration:

protected/config/console.php

Configuration

Besides the usual CClientScript properties the packager adds these other configuration options, which you can set in your main.php config file:

Command-line maintenance

This component comes with a maintenace command for yiic. It can be used to compress packages, reset packages or output details about compressed packages from the command line.

Note: It's important that the package configuration from your web configuration is also available in your console config. That means, you need have the same clientScript configuration in your console.php. You may want to use a shared include file to do so. If you want to compress from the command-line you also need to configure an asset manager and an alias for webroot. You also need to fix a problem with the request component which returns '.' as baseUrl on console:

Note 2: You need write permissions from the command line to the state.bin file in your protected/runtime directory, if you want to reset packages.

Compress a package:

./yiic packages compress --name=<packagename>

Show meta information about a compressed package:

./yiic packages info --name=<packagename>

Reset all compressed packages:

./yiic packages reset

Reset specific package:

./yiic packages reset --name=<packagename>

Advanced example: CSS assets

CSS files often contain relative URL references to some asset files (images). So if the compressed CSS file is published to the assets directory, these paths will be broken (except if we'd also publish the images, which we don't). As a workaround you can publish a CSS package into the same folder where the source files reside. Therefore you have to specify a baseUrl in your package.

Now you can register this CSS package with

Yii::app()->clientScript->registerPackage('forum-css');

Note: Here the web server process must have write permissions to the CSS folder.

Advanced example: media support for CSS

CSS packages can contain a media specification which will be used when the package is registered.

Advanced example: jQUery from CDN

If you want to use a CDN for jQuery you can configure it just as you would without the compressor. Everything will work when you register such a package:

Known Problems and Limitations

Changelog

1.0.4

1.0.3

1.0.2

1.0.0


All versions of packagecompressor with dependencies

PHP Build Version
Package Version
Requires php Version >=5.0.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 mikehaertl/packagecompressor contains the following files

Loading the files please wait ....