GithubHelp home page GithubHelp logo

yii2-dependencies's Introduction

yii2-dependencies

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist kuaukutsu/yii2-dependencies "*"

or add

"kuaukutsu/yii2-dependencies": "*"

to the require section of your composer.json.

Usage

Add the following in config/console.php:

    'controllerMap' => [
        'dependence' => [
            'class' => 'kuaukutsu\dependencies\DependenceController'
        ]
    ]

Configuration

To use this command, you should first create a configuration file to describe what asset bundles should be combined and how they should be grouped. You can use the dependence/template sub-command to generate a template first and then modify it to fit for your needs.

yii dependence/template dependence.php

The command generates a file named dependence.php in the current directory. The content of this file looks like the following:

    <?php
    /**
     * Configuration file for the "yii dependence" console command.
     */
    
    // In the console environment, some path aliases may not exist. Please define these:
    //Yii::setAlias('@webroot', __DIR__ . '/../web');
    //Yii::setAlias('@web', '/');

    return [
        // Asset manager configuration:
        'assetManager' => [
            'basePath' => '@webroot/assets',
            'baseUrl' => '@web',
        ],
        // Dependence manager configuration:
        'dependenceManager' => [
            'configPath' => '@webroot',
            'namespaceAsset' => 'app\\assets\\',
        ],
        // The list of asset bundles to dependence:
        'task' => [
            'all' => [
                'src' => [
                    '@app/assets'
                ]
            ],
            'yii' => [
                'src' => [
                    'yii\web\YiiAsset',
                    'yii\grid\GridViewAsset',
                    'yii\captcha\CaptchaAsset',
                    'yii\validators\ValidationAsset',
                    'yii\widgets\ActiveFormAsset',
                    'yii\widgets\MaskedInputAsset',
                    'yii\authclient\widgets\AuthChoiceAsset',
                ],
                'exclude' => [
                    'jquery.pjax.js'
                ]
            ],
            'single-page' => [
                'src' => [
                    '@app/views/default/index.php'
                ]
            ],
            'controller' => [
                'src' => [
                    '@app/controllers/DefaultController.php'
                ]
            ],
        ]
    ];

You should modify this file and specify which bundles you plan to include in the file dependencies.

With the configuration file, you can run the dependence command to generate a new files dependencies @webroot/all.json and @webroot/all-js.json and @webroot/all-css.json (dependenceManager['configPath'] + task['name'].json ):

yii dependence dependence.php

The generated files contain a list of dependencies in json format. How to use it, see Asset processing with Grunt

yii2-dependencies's People

Contributors

kuaukutsu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.