PHP code example of aleksender / yii2-morphy

1. Go to this page and download the library: Download aleksender/yii2-morphy 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/ */

    

aleksender / yii2-morphy example snippets


$morphy = new \aleksender\morphy\PhpMorphy();
$word = "КОТ";

if ($paradigms = $morphy->findWord($word)) {
    foreach ($paradigms as $paradigm) {
        foreach ($paradigm as $form) {
            echo $form->getWord() . "\n";
        }
    }
}

[
    ...
    'components' => [
        ...
        'morphy' => [
            'class' => \aleksender\morphy\PhpMorphy::class,
            'lang' => 'ru',
        ],
        ...
        
    ],
    ...
]

$morphy = Yii::$app->morphy;
$word = "КОТ";

if ($paradigms = $morphy->findWord($word)) {
    foreach ($paradigms as $paradigm) {
        foreach ($paradigm as $form) {
            echo $form->getWord() . "\n";
        }
    }
}