yiisoft/yii2-composer The composer plugin for Yii extension installer

composerextensioninstaller

logo-composer-transparent3.png

Yii 2 Composer Installer


This is the composer installer for Yii framework 2.0 extensions. It implements a new composer package type named yii2-extension, which should be used by all Yii 2 extensions if they are distributed as composer packages.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build status

Usage

The Yii 2 Composer Installer is automatically installed with when installing the framework via Composer.

To use Yii 2 composer installer, simply set the package type to be yii2-extension in your composer.json, like the following:

{
    "type": "yii2-extension",
    "require": {
        "yiisoft/yii2": "~2.0.0"
    },
    ...
}

You may specify a bootstrapping class in the extra section. The init() method of the class will be executed each time the Yii 2 application is responding to a request. For example,

{
    "type": "yii2-extension",
    ...,
    "extra": {
        "bootstrap": "yii\\jui\\Extension"
    }
}

The Installer class also implements a static method postCreateProject() that can be called after a Yii 2 project is created, through the post-create-project-cmd composer script. A similar method exists for running tasks after each composer install call, which is postInstall(). These methods allow to run other Installer class methods like setPermission() or generateCookieValidationKey(), depending on the corresponding parameters set in the extra section of the composer.json file. For example,

{
    "name": "yiisoft/yii2-app-basic",
    "type": "project",
    ...
    "scripts": {
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject"
        ],
        "post-install-cmd": [
            "yii\\composer\\Installer::postInstall"
        ]
    },
    "extra": {
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0755"
                }
            ]
        },
        "yii\\composer\\Installer::postInstall": {
            "copyFiles": [
                {
                    "config/templates/console-local.php": "config/console-local.php",
                    "config/templates/web-local.php": "config/web-local.php",
                    "config/templates/db-local.php": "config/db-local.php",
                    "config/templates/cache.json": ["runtime/cache.json", true]
                }
            ],
            "generateCookieValidationKey": [
                "config/web-local.php"
            ]
        }
    }
}

Changelog

Yii Framework 2 composer extension Change Log

2.0.11 under development

  • Enh #38: Use random_bytes instead of openssl_random_pseudo_bytes if available (fetus_hina)

2.0.10 June 24, 2020

  • Enh #31: Add Composer 2 parallel unzip compatibility (samdark)

2.0.9 April 20, 2020

  • Bug #30: Fix PHP error when upgrading/downgrading a Yii2 extension (brandonkelly)
  • Enh #27: Support for Composer 2 (brandonkelly, cebe)

2.0.8 July 16, 2019

  • Bug #23: Fixed another an error that would occur if the Zend OPcache extension was installed, but its "restrict_api" setting was enabled (Lachee)

2.0.7 July 05, 2018

  • Bug #18: Fixed an error that would occur if the Zend OPcache extension was installed, but its "restrict_api" setting was enabled (angrybrad)

2.0.6 March 21, 2018

  • Bug #16: Upgrade notes were not shown when upgrading from a patch version (cebe)

2.0.5 December 20, 2016

  • Bug #11: generateCookieValidationKey() now saves config file only when cookieValidationKey was generated (rob006)
  • Enh #10: Added yii\composer\Installer::postInstall() method (rob006)
  • Enh #12: Added yii\composer\Installer::copyFiles() method (rob006)
  • Enh #14: A note about yii UPGRADE notes file is shown after upgrading Yii to make user aware of it (cebe)

2.0.4 February 06, 2016

  • Bug #7735: Composer failed to install extensions with multiple base paths in "psr-4" autoload section (cebe)
  • Enh #2: Better error handling for the case when installer is unable to change permissions (dbavscc)
  • Enh #3: loadExtensions() and saveExtensions() now access EXTENSION_FILE constant with late static binding (karneds)

2.0.3 March 01, 2015

  • no changes in this release.

2.0.2 January 11, 2015

  • no changes in this release.

2.0.1 December 07, 2014

  • no changes in this release.

2.0.0 October 12, 2014

  • no changes in this release.

2.0.0-rc September 27, 2014

  • Bug #3438: Fixed support for non-lowercase package names (cebe)
  • Chg: Added yii\composer\Installer::postCreateProject() and modified the syntax of calling installer methods in composer.json (qiangxue)

2.0.0-beta April 13, 2014

  • Bug #1480: Fixed issue with creating extensions.php when php opcache is enabled (cebe)
  • Enh: Added support for installing packages conforming to PSR-4 standard (qiangxue)

2.0.0-alpha, December 1, 2013

  • Initial release.

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



2.0.10 is the latest of 14 releases



BSD-3-Clause license
Stats
85 github stars & 30 github forks
11000 downloads in the last day
257243 downloads in the last 30 days
21053917 total downloads