fecony / yandex-speller
Laravel Wrapper for Yandex Speller API
Requires
- php: >=7.3
- ext-json: *
- guzzlehttp/guzzle: ^7.2
- illuminate/support: ^8.19
Requires (Dev)
- orchestra/testbench: ^6.7
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
- sempro/phpunit-pretty-print: ^1.3
README
Simple Laravel Yandex Speller API response wrapper.
Unfortunately Yandex Speller is not supported officially now 🙁
Basic spellchecking is working, but options have no effect on API work...
Installation
You can install the package via composer:
composer require fecony/yandex-speller
You can publish the package config file
php artisan vendor:publish --tag=yandex-speller
Basic Usage
There are to ways of utilizing the package: using the facade, or using the helper function. On either way you will get the same result, it is totally up to you.
Facade:
use Fecony\YandexSpeller\Facade\YandexSpeller; ... public function index() { $result = YandexSpeller::check('Helllo world!'); // Do whatever you want with results // $this->someService->swapWords($result->getData()->data); }
Helper function:
public function index() { $result = speller('Helllo world!'); // Do whatever you want with results // $this->someService->swapWords($result->getData()->data); }
Advanced usage
Both YandexSpeller::check()
method and speller()
helper accept four parameters:
string | array $text
text sting or array of strings to check spelling.string | null $lang
used to rewrite config defined $lang parameter, comma separated languages, optional.int | null $options
used to rewrite config defined $options parameter, sum of possible options, optional.string | null $format
used to rewrite config defined $format parameter, 'plain' or 'html', optional.
Configuration
If you need to customize the default config, you can do it directly on the yandex-speller.php
configuration file.
option | default | description |
---|---|---|
lang | 'ru,en' | This option specifies the default languages of the text to be checked. The parameter value should be comma separated. |
format | 'plain' | This option specifies the default format of the text to be checked. |
options | 0 | This option specifies the behaviour of the API. The parameter value is the sum of the option values. Refer to: https://yandex.ru/dev/speller/doc/dg/reference/speller-options.html |
Testing
composer test
Roadmap
This package is basic wrapper to make call to Yandex Speller API, it is possible to use any parameters that Yandex Speller is supporting for now. New Features may be made in case you find interesting use cases.
For example:
- Wrap result to use in other methods.
- Return text with suggestions applied.
- etc...
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.