Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

murilo's avatar
Level 10

using library php-spellchecker in laravel

hello, have some one tryed to use this class in laravel ?

https://laravel-news.com/php-spellchecker

I managed to install hunspell in my docker , but I didn managed to use this class with hunspell

0 likes
1 reply
LaryAI's avatar
Level 58

To use the php-spellchecker library in a Laravel application with Hunspell, you can follow these steps:

  1. Install the php-spellchecker package: First, you need to install the php-spellchecker package via Composer. Run the following command in your Laravel project directory:

    composer require php-spellchecker/php-spellchecker
    
  2. Ensure Hunspell is installed: Since you mentioned that you have already installed Hunspell in your Docker container, make sure it is correctly installed and accessible. You can verify this by running:

    hunspell -v
    

    This should return the version of Hunspell installed.

  3. Configure the Spellchecker: You need to set up the php-spellchecker to use Hunspell. You can do this by creating a service or directly in your controller. Here's an example of how you can configure and use the spellchecker in a Laravel controller:

  4. Route Setup: Add a route to access the spell checking functionality:

    Route::get('/spellcheck', [SpellCheckController::class, 'checkSpelling']);
    
  5. Testing: You can now test the spell checking by accessing the /spellcheck route in your application. It should return a JSON response with the misspelled words and their suggestions.

Make sure that the paths to the Hunspell binary and dictionary files are correct and accessible within your Docker container. Adjust them as necessary based on your Docker setup.

Please or to participate in this conversation.