PHP code example of prokhonenkov / yii2-word-counter
1. Go to this page and download the library: Download prokhonenkov/yii2-word-counter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
prokhonenkov / yii2-word-counter example snippets
return [
// ... your config
'components' => [
'wordCounter' => [
'class' => \prokhonenkov\wordcounter\WordCounter::class,
],
]
];
class TextController extends \yii\console\Controller
{
public function actionCountWords(string $fileName)
{
$result = \Yii::$app->wordCounter
->setFilePath($fileName)
->count();
print_r($result);
}
}
php composer.phar