thangnm93/yii2-decomposer

A Yii2 package to decompose your installed packages, their dependencies, your app & server environment

v0.1.5 2022-07-19 11:10 UTC

This package is auto-updated.

Last update: 2024-11-19 16:02:19 UTC


README

Decomposer Extension for Yii 2


For license information check the LICENSE-file.

Latest Stable Version Total Downloads License PRs

Introduction

Yii 2 Decomposer decomposes and lists all the installed packages and their dependencies along with the Yii 2 Framework & the Server environment details your app is running in. All these just on the hit of a single route at your-domain/decomposer.

The demo of this extension is available at HERE

This extension base on lubusIN/laravel-decomposer wrapper for Laravel user component.

Requirements

Installation

The preferred way to install this extension is through composer.

Either run

composer require thangnm93/yii2-decomposer

or add

"thangnm93/yii2-decomposer": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply modify your application configuration as follows:

return [
    'bootstrap' => ['decomposer'],
    'modules' => [
        'decomposer' => [
            'class' => 'thangnm93\decomposer\Module',
        ],
        // ...
    ],
    ...
];

Config common/config/main.php to use Yii::$app->decompose

return [
    'components' => [
        'decompose' => [
            'class' => 'thangnm93\decomposer\Decomposer',
        ],
    ],
    ...
];

Get Report as an Array

  • You might want to access the Decomposer Report in your code so that it could be passed to any third party services like Bugsnag, etc. or maybe you want to log it yourself somewhere if required.

  • The getReportArray() helper method has been introduced to solve the same requirement.

  • First use the Decomposer class at the top as follows:

    use thangnm93\decomposer\helpers\DecomposerHelper;
  • Then use the getReportArray() helper method as follows:

    $decomposerStats = DecomposerHelper::getReportArray();
  • It returns a multi-dimensional associative array with 4 keys: Server Environment, Yii 2 Environment & Installed Packages & Extra stats(If you or a package in your app have added any) having the respective details as an associative array.

Get Report as JSON

  • You might want to access the same Decomposer Report as JSON

  • The getReportJson() helper method has been introduced to solve the same requirement.

  • First use the Decomposer class at the top as follows:

    use thangnm93\decomposer\helpers\DecomposerHelper;
  • Then use the getReportJson() helper method as follows:

    $decomposerStats = DecomposerHelper::getReportJson();
  • It returns the report as JSON

Testing

$ ./vendor/bin/phpunit --testdox --coverage-text --coverage-clover=coverage.clover

Contributing

Thank you for considering contributing to the Yii 2 Decomposer. You can read the contribution guide lines here

Security

If you discover any security related issues, please email to contact@thangnm.info.

Credits