prokhonenkov / yii2-word-counter
The word counter
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.1
- yiisoft/yii2: ~2.0.0
Requires (Dev)
- codeception/codeception: ^4.1
- codeception/module-asserts: ^1.1
- codeception/module-yii2: ^1.1
- codeception/verify: ^1.2
This package is auto-updated.
Last update: 2024-11-11 15:19:13 UTC
README
This extension count words and sort them by the number and alphabet.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require prokhonenkov/yii2-word-counter
or add
"prokhonenkov/yii2-word-counter": "*"
to the require section of your composer.json
file.
Configuration
Add component declaration to your config file for console config:
<?php return [ // ... your config 'components' => [ 'wordCounter' => [ 'class' => \prokhonenkov\wordcounter\WordCounter::class, ], ] ];
Usage
Pass filepath to setFilePath method and invoke count method.
class TextController extends \yii\console\Controller { public function actionCountWords(string $fileName) { $result = \Yii::$app->wordCounter ->setFilePath($fileName) ->count(); print_r($result); } }