lajax/yii2-project-scanner

Yii2 Project Scanner Extension

Installs: 231

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.0 2016-09-06 18:35 UTC

This package is auto-updated.

Last update: 2024-12-17 22:07:52 UTC


README

Yii2 Project Scanner Extension

Installation

##composer

The preferred way to install this extension is through composer.

Either run

composer require lajax/yii2-project-scanner

or add

"lajax/yii2-project-scanner": "^1.0.0"

to the require section of your composer.json file.

Usage

##Configs

###Minimal configs

[
    'components' => [
        // ...
        'scanner' =>  lajax\projectscanner\Scanner::className(),
        // ...
    ],
],

###Full configs

[
    'components' => [
        // ...
        'scanner' =>  [
            'class' => lajax\projectscanner\Scanner::className(),
            'scanTimeLimit' => null,
            'ignoredCategories' => [],
            'ignoredItems' => [
                '.svn',
                '.git',
                '.gitignore',
                '.gitattributes',
                '.gitkeep',
                '.hgignore',
                '.hgkeep',
                '/messages',
                '/BaseYii.php',
                'runtime',
                'bower',
                'nikic',
            ],
            'roots' => [
                '@backend',
                '@common',
                '@console',
                '@frontend',
                '@vendor',
            ],
            'scanners' => [
                'dbScanner' => [
                    'class' => lajax\projectscanner\scanners\DbScanner::className(),
                    'category' => 'database',
                    'tables' => [
                        [
                            'connection' => 'db',
                            'table' => 'language',
                            'columns' => ['name', 'name_ascii'],
                            'category' => 'tableName',
                        ],
                        [
                            'connection' => 'db',
                            'table' => 'tag',
                            'columns' => ['name'],
                            'category' => 'tableName',
                        ],
                        [
                            'connection' => 'db',
                            'table' => 'category',
                            'columns' => ['name', 'description'],
                        ],
                    ],
                ],
                'jsScanner' => [
                    'class' => lajax\projectscanner\scanners\JsScanner::className(),
                    'extension' => '*.js',
                    'translators' => ['lajax.t'],
                    'category' => 'javascript',

                ],
                'phpArrayScanner' => [
                    'class' => lajax\projectscanner\scanners\PhpArrayScanner::className(),
                    'extension' => '*.php',
                    'category' => 'array',
                    'patternArrayTranslator' => '#\@translate[^\$]+(?P<translator>[\w\d\s_]+[^\(\[]+)#s',

                ],
                'phpFunctionScanner' => [
                    'class' => lajax\projectscanner\scanners\PhpFunctionScanner::className(),
                    'extension' => '*.php',
                    'translators' => ['::t'],
                ],
            ],
        ],
        // ...
    ],
],

##Scanning project

```php
$scannerResult = \Yii::$app->scanner->execute();

###result

$scannerResult->languageElements;       *Array* List of language elements.
                                        [
                                            ['category' => 'messageCategory', 'message' => 'languageElement'],
                                            ['category' => 'messageCategory', 'message' => 'languageElement'],
                                            // ...
                                        ]
$scannerResult->numberOfLanguageElements;  *Integer* Number of language elements.

$scannerResult->filteredLanguageElements;   *Array* List of language elements.
                                        [
                                            'messageCategory' => [
                                                'languageElement' => true
                                            ]
                                        ]
                                        [
                                            'messageCategory' => [
                                                'languageElement' => true
                                            ]
                                        ]
                                        [
                                            'messageCategory' => [
                                                'languageElement' => true
                                            ]
                                        ]

Links