I did a lot of R&D how to make it work with PHP and details are given below:
Download the community version of tinyMCE form the tinyMCE website. In the download directory, there is a folder spellcheck under plugin folder in which there is a file plugin.min.js. Reference to this file needs to add in the client side code.
Download the PHP spell check code from the given URL i.e
https://www.tinymce.com/docs/get-started/spellchecking/#phpspellcheckercomponent
Host the same on PHP server. And make sure that the enchant option is enabled on PHP server.
You can check the same via phpserverurl/spellchecker/info.php, find the enchant module [to check the enchant option is enabled or not, on PHP server][1][1]: https://i.stack.imgur.com/fBzDm.png
If the file phpserverurl/spellchecker/info.php does not exist, then create a new file there and write the following code:
<?php
phpinfo();
?>
Client-side code for tinyMCE:
// Scripts reference
tinymce.init
({
mode: "exact",
selector: 'textarea',
height: 540,
with: 'auto',
menubar: false,
toolbar: 'spellchecker | formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | undo redo | removeformat',
toolbar_items_size: 'small',
branding: false, // To disable "Powered by TinyMCE"
statusbar: false,
plugins: "spellchecker",
spellchecker_rpc_url: 'phpserverurl/spellchecker/spellchecker.php', // this is url of php server where spellchecker code is hosted
spellchecker_languages: 'en'
});
Click on spellcheck icon when the editor is rendered and it will give you the suggestions to correct the misspelled words.
If your tinyMCE code and spellchecker code is hosted on a different server then add a line of code in the header of spellchecker.php file i.e given below
header ("Access-Control-Allow-Origin: *");
header ("Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS");
header ("Access-Control-Allow-Headers: *");
In order to resolve the cross-domain request, otherwise, there is no need to add the above line of code.
Thanks.