# AssetController

> Allows you to combine and compress your JavaScript and CSS files.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [console](/docs/api/yii/console/index.md) › [controllers](/docs/api/yii/console/controllers/index.md) › AssetController

| class | `yii\console\controllers\AssetController` |
| --- | --- |
| Extends | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) » [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) » [`yii\base\Component`](/docs/api/yii/base/component/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\ViewContextInterface`](/docs/api/yii/base/viewcontextinterface/index.md), [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Since | 2.0 |
| Source | [`framework/console/controllers/AssetController.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/console/controllers/AssetController.php#L54) |

Allows you to combine and compress your JavaScript and CSS files.

Usage:

1. Create a configuration file using the `template` action:

   yii asset/template /path/to/myapp/config.php

2. Edit the created config file, adjusting it for your web application needs.
3. Run the 'compress' action, using created config:

   yii asset /path/to/myapp/config.php /path/to/myapp/config/assets_compressed.php

4. Adjust your web application config to use compressed assets.

Note: in the console environment some [path aliases](/docs/guide/concept-aliases/index.md) like `@webroot` and `@web` may not exist,
so corresponding paths inside the configuration should be specified directly.

Note: by default this command relies on an external tools to perform actual files compression,
check [`$jsCompressor`](/docs/api/yii/console/controllers/assetcontroller/index.md#property-jsCompressor) and [`$cssCompressor`](/docs/api/yii/console/controllers/assetcontroller/index.md#property-cssCompressor) for more details.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-action"></span>[`$action`](/docs/api/yii/base/controller/index.md#property-action) | [`yii\base\Action`](/docs/api/yii/base/action/index.md)`<static>\|null` | The action that is currently being executed. Default: `null`. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="property-assetManager"></span>`$assetManager` | [`yii\web\AssetManager`](/docs/api/yii/web/assetmanager/index.md)`\|array` | Asset manager instance or its array configuration. | `AssetController` |
| <span id="property-behaviors"></span>[`$behaviors`](/docs/api/yii/base/component/index.md#property-behaviors) read-only | `array<`[`yii\base\Behavior`](/docs/api/yii/base/behavior/index.md)`<static>>` | List of behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="property-bundles"></span>`$bundles` | `array` | List of asset bundles to be compressed. Default: `[]`. | `AssetController` |
| <span id="property-color"></span>[`$color`](/docs/api/yii/console/controller/index.md#property-color) | `bool\|null` | Whether to enable ANSI color in the output. Default: `null`. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| [`$cssCompressor`](#property-cssCompressor) | `string\|callable` | CSS file compressor. Default: `'java -jar yuicompressor.jar --type css {from} -o {to}'`. | `AssetController` |
| <span id="property-defaultAction"></span>`$defaultAction` | `string` | Controller default action ID. Default: `'compress'`. | `AssetController` |
| [`$deleteSource`](#property-deleteSource) | `bool` | Whether to delete asset source files after compression. Default: `false`. Available since 2.0.10. | `AssetController` |
| <span id="property-help"></span>[`$help`](/docs/api/yii/console/controller/index.md#property-help) | `bool` | Whether to display help information about current command. Default: `false`. Available since 2.0.10. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="property-helpSummary"></span>[`$helpSummary`](/docs/api/yii/console/controller/index.md#property-helpSummary) read-only | `string` | The one-line short summary describing this controller. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="property-id"></span>[`$id`](/docs/api/yii/base/controller/index.md#property-id) | `string` | The ID of this controller. Default: `null`. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="property-interactive"></span>[`$interactive`](/docs/api/yii/console/controller/index.md#property-interactive) | `bool` | Whether to run the command interactively. Default: `true`. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| [`$jsCompressor`](#property-jsCompressor) | `string\|callable` | JavaScript file compressor. Default: `'java -jar compiler.jar --js {from} --js_output_file {to}'`. | `AssetController` |
| <span id="property-layout"></span>[`$layout`](/docs/api/yii/base/controller/index.md#property-layout) | `string\|null\|false` | The name of the layout to be applied to this controller's views. Default: `null`. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="property-module"></span>[`$module`](/docs/api/yii/base/controller/index.md#property-module) | `yii\base\T` | The module that this controller belongs to. Default: `null`. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="property-modules"></span>[`$modules`](/docs/api/yii/base/controller/index.md#property-modules) read-only | [`yii\base\Module`](/docs/api/yii/base/module/index.md)`[]` | All ancestor modules that this controller is located within. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="property-passedOptions"></span>[`$passedOptions`](/docs/api/yii/console/controller/index.md#property-passedOptions) read-only | `array` | The names of the options passed during execution. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="property-passedOptionValues"></span>[`$passedOptionValues`](/docs/api/yii/console/controller/index.md#property-passedOptionValues) read-only | `array` | The properties corresponding to the passed options. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="property-request"></span>[`$request`](/docs/api/yii/console/controller/index.md#property-request) | [`yii\console\Request`](/docs/api/yii/console/request/index.md) | The request object. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="property-response"></span>[`$response`](/docs/api/yii/console/controller/index.md#property-response) | [`yii\console\Response`](/docs/api/yii/console/response/index.md) | The response object. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="property-route"></span>[`$route`](/docs/api/yii/base/controller/index.md#property-route) read-only | `string` | The route (module ID, controller ID and action ID) of the current request. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="property-silentExitOnException"></span>[`$silentExitOnException`](/docs/api/yii/console/controller/index.md#property-silentExitOnException) | `bool\|null` | If true - script finish with `ExitCode::OK` in case of exception. false - `ExitCode::UNSPECIFIED_ERROR`. Default: `null`. Available since 2.0.36. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| [`$targets`](#property-targets) | `array` | List of asset bundles, which represents output compressed files. Default: `[]`. | `AssetController` |
| <span id="property-uniqueId"></span>[`$uniqueId`](/docs/api/yii/base/controller/index.md#property-uniqueId) read-only | `string` | The controller ID that is prefixed with the module ID (if any). | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="property-view"></span>[`$view`](/docs/api/yii/base/controller/index.md#property-view) | [`yii\base\View`](/docs/api/yii/base/view/index.md)`\|`[`yii\web\View`](/docs/api/yii/web/view/index.md) | The view object that can be used to render views or view files. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="property-viewPath"></span>[`$viewPath`](/docs/api/yii/base/controller/index.md#property-viewPath) | `string` | The directory containing the view files for this controller. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/controller/index.md#method-__construct) |  | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/component/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__clone"></span>[`__clone()`](/docs/api/yii/base/component/index.md#method-__clone) | This method is called after the object is created by cloning an existing one. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/component/index.md#method-__get) | Returns the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/component/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/component/index.md#method-__set) | Sets the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/component/index.md#method-__unset) | Sets a component property to be null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`actionCompress()`](#method-actionCompress) | Combines and compresses the asset files according to the given configuration. | `AssetController` |
| <span id="method-actions"></span>[`actions()`](/docs/api/yii/base/controller/index.md#method-actions) | Declares external actions for the controller. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| [`actionTemplate()`](#method-actionTemplate) | Creates template of configuration file for [`actionCompress()`](/docs/api/yii/console/controllers/assetcontroller/index.md#method-actionCompress). | `AssetController` |
| <span id="method-afterAction"></span>[`afterAction()`](/docs/api/yii/base/controller/index.md#method-afterAction) | This method is invoked right after an action is executed. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-ansiFormat"></span>[`ansiFormat()`](/docs/api/yii/console/controller/index.md#method-ansiFormat) | Formats a string with ANSI codes. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-attachBehavior"></span>[`attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) | Attaches a behavior to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehaviors"></span>[`attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) | Attaches a list of behaviors to the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-beforeAction"></span>[`beforeAction()`](/docs/api/yii/console/controller/index.md#method-beforeAction) | This method is invoked right before an action is executed. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-behaviors"></span>[`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) | Returns a list of behaviors that this component should behave as. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-bindActionParams"></span>[`bindActionParams()`](/docs/api/yii/console/controller/index.md#method-bindActionParams) | Binds the parameters to the action. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/component/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/component/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| [`combineCssFiles()`](#method-combineCssFiles) | Combines CSS files into a single one. | `AssetController` |
| [`combineJsFiles()`](#method-combineJsFiles) | Combines JavaScript files into a single one. | `AssetController` |
| <span id="method-confirm"></span>[`confirm()`](/docs/api/yii/console/controller/index.md#method-confirm) | Asks user to confirm by typing y or n. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-createAction"></span>[`createAction()`](/docs/api/yii/base/controller/index.md#method-createAction) | Creates an action based on the given action ID. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-detachBehavior"></span>[`detachBehavior()`](/docs/api/yii/base/component/index.md#method-detachBehavior) | Detaches a behavior from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-detachBehaviors"></span>[`detachBehaviors()`](/docs/api/yii/base/component/index.md#method-detachBehaviors) | Detaches all behaviors from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-ensureBehaviors"></span>[`ensureBehaviors()`](/docs/api/yii/base/component/index.md#method-ensureBehaviors) | Makes sure that the behaviors declared in [`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) are attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-findLayoutFile"></span>[`findLayoutFile()`](/docs/api/yii/base/controller/index.md#method-findLayoutFile) | Finds the applicable layout file. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-getActionArgsHelp"></span>[`getActionArgsHelp()`](/docs/api/yii/console/controller/index.md#method-getActionArgsHelp) | Returns the help information for the anonymous arguments for the action. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-getActionHelp"></span>[`getActionHelp()`](/docs/api/yii/console/controller/index.md#method-getActionHelp) | Returns the detailed help information for the specified action. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-getActionHelpSummary"></span>[`getActionHelpSummary()`](/docs/api/yii/console/controller/index.md#method-getActionHelpSummary) | Returns a one-line short summary describing the specified action. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-getActionOptionsHelp"></span>[`getActionOptionsHelp()`](/docs/api/yii/console/controller/index.md#method-getActionOptionsHelp) | Returns the help information for the options for the action. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| [`getAssetManager()`](#method-getAssetManager) | Returns the asset manager instance. | `AssetController` |
| <span id="method-getBehavior"></span>[`getBehavior()`](/docs/api/yii/base/component/index.md#method-getBehavior) | Returns the named behavior object. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehaviors"></span>[`getBehaviors()`](/docs/api/yii/base/component/index.md#method-getBehaviors) | Returns all behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getHelp"></span>[`getHelp()`](/docs/api/yii/console/controller/index.md#method-getHelp) | Returns help information for this controller. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-getHelpSummary"></span>[`getHelpSummary()`](/docs/api/yii/console/controller/index.md#method-getHelpSummary) | Returns one-line short summary describing this controller. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-getModules"></span>[`getModules()`](/docs/api/yii/base/controller/index.md#method-getModules) | Returns all ancestor modules of this controller. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-getOptionValues"></span>[`getOptionValues()`](/docs/api/yii/console/controller/index.md#method-getOptionValues) | Returns properties corresponding to the options for the action id Child classes may override this method to specify possible properties. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-getPassedOptions"></span>[`getPassedOptions()`](/docs/api/yii/console/controller/index.md#method-getPassedOptions) | Returns the names of valid options passed during execution. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-getPassedOptionValues"></span>[`getPassedOptionValues()`](/docs/api/yii/console/controller/index.md#method-getPassedOptionValues) | Returns the properties corresponding to the passed options. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-getRoute"></span>[`getRoute()`](/docs/api/yii/base/controller/index.md#method-getRoute) | Returns the route of the current request. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-getUniqueId"></span>[`getUniqueId()`](/docs/api/yii/base/controller/index.md#method-getUniqueId) | Returns the unique ID of the controller. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-getView"></span>[`getView()`](/docs/api/yii/base/controller/index.md#method-getView) | Returns the view object that can be used to render views or view files. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-getViewPath"></span>[`getViewPath()`](/docs/api/yii/base/controller/index.md#method-getViewPath) | Returns the directory containing view files for this controller. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-hasEventHandlers"></span>[`hasEventHandlers()`](/docs/api/yii/base/component/index.md#method-hasEventHandlers) | Returns a value indicating whether there is any handler attached to the named event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/component/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/component/index.md#method-hasProperty) | Returns a value indicating whether a property is defined for this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-init"></span>[`init()`](/docs/api/yii/base/controller/index.md#method-init) | Initializes the object. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-isColorEnabled"></span>[`isColorEnabled()`](/docs/api/yii/console/controller/index.md#method-isColorEnabled) | Returns a value indicating whether ANSI color is enabled. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-off"></span>[`off()`](/docs/api/yii/base/component/index.md#method-off) | Detaches an existing event handler from this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-on"></span>[`on()`](/docs/api/yii/base/component/index.md#method-on) | Attaches an event handler to an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-optionAliases"></span>[`optionAliases()`](/docs/api/yii/console/controller/index.md#method-optionAliases) | Returns option alias names. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-options"></span>[`options()`](/docs/api/yii/console/controller/index.md#method-options) | Returns the names of valid options for the action (id) An option requires the existence of a public member variable whose name is the option name. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-prompt"></span>[`prompt()`](/docs/api/yii/console/controller/index.md#method-prompt) | Prompts the user for input and validates it. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-render"></span>[`render()`](/docs/api/yii/base/controller/index.md#method-render) | Renders a view and applies layout if available. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-renderContent"></span>[`renderContent()`](/docs/api/yii/base/controller/index.md#method-renderContent) | Renders a static string by applying a layout. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-renderFile"></span>[`renderFile()`](/docs/api/yii/base/controller/index.md#method-renderFile) | Renders a view file. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-renderPartial"></span>[`renderPartial()`](/docs/api/yii/base/controller/index.md#method-renderPartial) | Renders a view without applying layout. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-run"></span>[`run()`](/docs/api/yii/base/controller/index.md#method-run) | Runs a request specified in terms of a route. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-runAction"></span>[`runAction()`](/docs/api/yii/console/controller/index.md#method-runAction) | Runs an action with the specified action ID and parameters. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-select"></span>[`select()`](/docs/api/yii/console/controller/index.md#method-select) | Gives the user an option to choose from. Giving '?' as an input will show a list of options to choose from and their explanations. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| [`setAssetManager()`](#method-setAssetManager) | Sets asset manager instance or configuration. | `AssetController` |
| <span id="method-setView"></span>[`setView()`](/docs/api/yii/base/controller/index.md#method-setView) | Sets the view object to be used by this controller. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-setViewPath"></span>[`setViewPath()`](/docs/api/yii/base/controller/index.md#method-setViewPath) | Sets the directory that contains the view files. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="method-stderr"></span>[`stderr()`](/docs/api/yii/console/controller/index.md#method-stderr) | Prints a string to STDERR. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-stdout"></span>[`stdout()`](/docs/api/yii/console/controller/index.md#method-stdout) | Prints a string to STDOUT. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`adjustCssUrl()`](#method-adjustCssUrl) protected | Adjusts CSS content allowing URL references pointing to the original resources. | `AssetController` |
| [`adjustDependency()`](#method-adjustDependency) protected | Adjust dependencies between asset bundles in the way source bundles begin to depend on output ones. | `AssetController` |
| <span id="method-bindInjectedParams"></span>[`bindInjectedParams()`](/docs/api/yii/base/controller/index.md#method-bindInjectedParams) protected final | Fills parameters based on types and names in action method signature. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| [`buildTarget()`](#method-buildTarget) protected | Builds output asset bundle. | `AssetController` |
| [`compressCssFiles()`](#method-compressCssFiles) protected | Compresses given CSS files and combines them into the single one. | `AssetController` |
| [`compressJsFiles()`](#method-compressJsFiles) protected | Compresses given JavaScript files and combines them into the single one. | `AssetController` |
| <span id="method-getActionMethodReflection"></span>[`getActionMethodReflection()`](/docs/api/yii/console/controller/index.md#method-getActionMethodReflection) protected |  | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| [`loadBundles()`](#method-loadBundles) protected | Creates full list of source asset bundles. | `AssetController` |
| [`loadConfiguration()`](#method-loadConfiguration) protected | Applies configuration from the given file to self instance. | `AssetController` |
| [`loadDependency()`](#method-loadDependency) protected | Loads asset bundle dependencies recursively. | `AssetController` |
| [`loadTargets()`](#method-loadTargets) protected | Creates full list of output asset bundles. | `AssetController` |
| <span id="method-parseDocCommentDetail"></span>[`parseDocCommentDetail()`](/docs/api/yii/console/controller/index.md#method-parseDocCommentDetail) protected | Returns full description from the docblock. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-parseDocCommentSummary"></span>[`parseDocCommentSummary()`](/docs/api/yii/console/controller/index.md#method-parseDocCommentSummary) protected | Returns the first line of docblock. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| <span id="method-parseDocCommentTags"></span>[`parseDocCommentTags()`](/docs/api/yii/console/controller/index.md#method-parseDocCommentTags) protected | Parses the comment block into tags. | [`yii\console\Controller`](/docs/api/yii/console/controller/index.md) |
| [`registerBundle()`](#method-registerBundle) protected | Registers asset bundles including their dependencies. | `AssetController` |
| [`saveTargets()`](#method-saveTargets) protected | Saves new asset bundles configuration. | `AssetController` |

## Events

| Event | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="event-EVENT_BEFORE_ACTION"></span>[`EVENT_BEFORE_ACTION`](/docs/api/yii/base/controller/index.md#event-EVENT_BEFORE_ACTION) | [`yii\base\ActionEvent`](/docs/api/yii/base/actionevent/index.md) | An event raised right before executing a controller action. Event name: `'beforeAction'`. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |
| <span id="event-EVENT_AFTER_ACTION"></span>[`EVENT_AFTER_ACTION`](/docs/api/yii/base/controller/index.md#event-EVENT_AFTER_ACTION) | [`yii\base\ActionEvent`](/docs/api/yii/base/actionevent/index.md) | An event raised right after executing a controller action. Event name: `'afterAction'`. | [`yii\base\Controller`](/docs/api/yii/base/controller/index.md) |

## Property details

### $cssCompressor <span id="property-cssCompressor"></span>

```php
public string|callable $cssCompressor = 'java -jar yuicompressor.jar --type css {from} -o {to}'
```

CSS file compressor.

If a string, it is treated as shell command template, which should contain
placeholders {from} - source file name - and {to} - output file name.
Otherwise, it is treated as PHP callback, which should perform the compression.

Default value relies on usage of "YUI Compressor"

### $deleteSource <span id="property-deleteSource"></span>

```php
public bool $deleteSource = false
```

Whether to delete asset source files after compression.

This option affects only those bundles, which have [`AssetBundle::$sourcePath`](/docs/api/yii/web/assetbundle/index.md#property-sourcePath) is set.

**Since**

2.0.10

### $jsCompressor <span id="property-jsCompressor"></span>

```php
public string|callable $jsCompressor = 'java -jar compiler.jar --js {from} --js_output_file {to}'
```

JavaScript file compressor.

If a string, it is treated as shell command template, which should contain
placeholders {from} - source file name - and {to} - output file name.
Otherwise, it is treated as PHP callback, which should perform the compression.

Default value relies on usage of "Closure Compiler"

### $targets <span id="property-targets"></span>

```php
public array $targets = []
```

List of asset bundles, which represents output compressed files.

You can specify the name of the output compressed file using 'css' and 'js' keys:
For example:

```
'app\config\AllAsset' => [
    'js' => 'js/all-{hash}.js',
    'css' => 'css/all-{hash}.css',
    'depends' => [ ... ],
]
```

File names can contain placeholder "{hash}", which will be filled by the hash of the resulting file.

You may specify several target bundles in order to compress different groups of assets.
In this case you should use 'depends' key to specify, which bundles should be covered with particular
target bundle. You may leave 'depends' to be empty for single bundle, which will compress all remaining
bundles in this case.
For example:

```
'allShared' => [
    'js' => 'js/all-shared-{hash}.js',
    'css' => 'css/all-shared-{hash}.css',
    'depends' => [
        // Include all assets shared between 'backend' and 'frontend'
        'yii\web\YiiAsset',
        'app\assets\SharedAsset',
    ],
],
'allBackEnd' => [
    'js' => 'js/all-{hash}.js',
    'css' => 'css/all-{hash}.css',
    'depends' => [
        // Include only 'backend' assets:
        'app\assets\AdminAsset'
    ],
],
'allFrontEnd' => [
    'js' => 'js/all-{hash}.js',
    'css' => 'css/all-{hash}.css',
    'depends' => [], // Include all remaining assets
],
```

## Method details

### actionCompress() <span id="method-actionCompress"></span>

```php
public function actionCompress(string $configFile, string $bundleFile): mixed
```

Combines and compresses the asset files according to the given configuration.

During the process new asset bundle configuration file will be created.
You should replace your original asset bundle configuration with this file in order to use compressed files.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$configFile` | `string` | Configuration file name. |
| `$bundleFile` | `string` | Output asset bundles configuration file name. |

**Returns**

`mixed`

### actionTemplate() <span id="method-actionTemplate"></span>

```php
public function actionTemplate(string $configFile): int
```

Creates template of configuration file for [`actionCompress()`](/docs/api/yii/console/controllers/assetcontroller/index.md#method-actionCompress).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$configFile` | `string` | Output file name. |

**Returns**

`int`: CLI exit code

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure.

### combineCssFiles() <span id="method-combineCssFiles"></span>

```php
public function combineCssFiles(array $inputFiles, string $outputFile): mixed
```

Combines CSS files into a single one.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$inputFiles` | `array` | Source file names. |
| `$outputFile` | `string` | Output file name. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure.

### combineJsFiles() <span id="method-combineJsFiles"></span>

```php
public function combineJsFiles(array $inputFiles, string $outputFile): mixed
```

Combines JavaScript files into a single one.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$inputFiles` | `array` | Source file names. |
| `$outputFile` | `string` | Output file name. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure.

### getAssetManager() <span id="method-getAssetManager"></span>

```php
public function getAssetManager(): yii\web\AssetManager
```

Returns the asset manager instance.

**Returns**

[`yii\web\AssetManager`](/docs/api/yii/web/assetmanager/index.md): Asset manager instance.

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on invalid configuration.

### setAssetManager() <span id="method-setAssetManager"></span>

```php
public function setAssetManager(yii\web\AssetManager|array $assetManager): mixed
```

Sets asset manager instance or configuration.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$assetManager` | [`yii\web\AssetManager`](/docs/api/yii/web/assetmanager/index.md)`\|array` | Asset manager instance or its array configuration. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on invalid argument type.

### adjustCssUrl() <span id="method-adjustCssUrl"></span>

```php
protected function adjustCssUrl(string $cssContent, string $inputFilePath, string $outputFilePath): string
```

Adjusts CSS content allowing URL references pointing to the original resources.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$cssContent` | `string` | Source CSS content. |
| `$inputFilePath` | `string` | Input CSS file name. |
| `$outputFilePath` | `string` | Output CSS file name. |

**Returns**

`string`: Adjusted CSS content.

### adjustDependency() <span id="method-adjustDependency"></span>

```php
protected function adjustDependency(yii\web\AssetBundle[] $targets, yii\web\AssetBundle[] $bundles): yii\web\AssetBundle[]
```

Adjust dependencies between asset bundles in the way source bundles begin to depend on output ones.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$targets` | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]` | Output asset bundles. |
| `$bundles` | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]` | Source asset bundles. |

**Returns**

[`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]`: Output asset bundles.

### buildTarget() <span id="method-buildTarget"></span>

```php
protected function buildTarget(yii\web\AssetBundle $target, string $type, yii\web\AssetBundle[] $bundles): mixed
```

Builds output asset bundle.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$target` | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) | Output asset bundle |
| `$type` | `string` | Either 'js' or 'css'. |
| `$bundles` | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]` | Source asset bundles. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure.

### compressCssFiles() <span id="method-compressCssFiles"></span>

```php
protected function compressCssFiles(array $inputFiles, string $outputFile): mixed
```

Compresses given CSS files and combines them into the single one.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$inputFiles` | `array` | List of source file names. |
| `$outputFile` | `string` | Output file name. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure

### compressJsFiles() <span id="method-compressJsFiles"></span>

```php
protected function compressJsFiles(array $inputFiles, string $outputFile): mixed
```

Compresses given JavaScript files and combines them into the single one.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$inputFiles` | `array` | List of source file names. |
| `$outputFile` | `string` | Output file name. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure

### loadBundles() <span id="method-loadBundles"></span>

```php
protected function loadBundles(string[] $bundles): yii\web\AssetBundle[]
```

Creates full list of source asset bundles.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$bundles` | `string[]` | List of asset bundle names |

**Returns**

[`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]`: List of source asset bundles.

### loadConfiguration() <span id="method-loadConfiguration"></span>

```php
protected function loadConfiguration(string $configFile): mixed
```

Applies configuration from the given file to self instance.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$configFile` | `string` | Configuration file name. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure.

### loadDependency() <span id="method-loadDependency"></span>

```php
protected function loadDependency(yii\web\AssetBundle $bundle, array &$result): mixed
```

Loads asset bundle dependencies recursively.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$bundle` | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) | Bundle instance |
| `$result` | `array` | Already loaded bundles list. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure.

### loadTargets() <span id="method-loadTargets"></span>

```php
protected function loadTargets(array $targets, yii\web\AssetBundle[] $bundles): yii\web\AssetBundle[]
```

Creates full list of output asset bundles.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$targets` | `array` | Output asset bundles configuration. |
| `$bundles` | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]` | List of source asset bundles. |

**Returns**

[`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]`: List of output asset bundles.

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure.

### registerBundle() <span id="method-registerBundle"></span>

```php
protected function registerBundle(yii\web\AssetBundle[] $bundles, string $name, array &$registered): mixed
```

Registers asset bundles including their dependencies.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$bundles` | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]` | Asset bundles list. |
| `$name` | `string` | Bundle name. |
| `$registered` | `array` | Stores already registered names. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): if circular dependency is detected.

### saveTargets() <span id="method-saveTargets"></span>

```php
protected function saveTargets(yii\web\AssetBundle[] $targets, string $bundleFile): mixed
```

Saves new asset bundles configuration.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$targets` | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md)`[]` | List of asset bundles to be saved. |
| `$bundleFile` | `string` | Output file name. |

**Returns**

`mixed`

**Throws**

- [`yii\console\Exception`](/docs/api/yii/console/exception/index.md): on failure.