A PHP Pspell substitute for Google Spell Check XML API.
  • PHP 98.2%
  • Dockerfile 1.8%
Find a file
2026-10-21 17:30:02 +00:00
.github Add basic tests (yamllint and docker build test) 2026-10-21 17:30:02 +00:00
.htaccess Added Dockerfile 2021-09-26 22:16:31 +02:00
Dockerfile Update PHP to 8.5.12 2026-10-21 17:28:45 +00:00
index.php Avoid Undefined index warnings 2016-07-13 22:20:15 +02:00
INSTALL.txt Added Dockerfile 2021-09-26 22:16:31 +02:00
README.md Fix deprecation error and use same example texts 2026-01-06 17:21:19 +00:00
spell-check-library.php Fix deprecation error and use same example texts 2026-01-06 17:21:19 +00:00

google-spell-pspell

A PHP Pspell substitute for Google Spell Check XML API. Pspell is required in order to work on your server.

Why?

Google obviously shut down their Spell checking API (www.google.com/tbproxy/spell) on July 9th 2013, see here. The spell-check-library.php lib is a PHP Pspell substitute for Google Spell Check XML API using the same XML structure.

Usage

require_once('spell-check-library.php');
$content = "";
$options = array(
  "lang"            => 'en',
  "maxSuggestions"  => 10,
  "customDict"      => 0,
  "charset"         => 'utf-8'
);
$factory = new SpellChecker($options);

$spell = $factory->create(trim("Ths is a tst"));

header('Content-Type: text/xml; charset=UTF-8');
echo $spell->toXML();

Echoes Google-style XML like this:

<spellresult error="0" clipped="0" charschecked="12">
    <c o="0" l="3" s="1">This Th's Thus Th HS</c>
    <c o="9" l="3" s="1">test tat ST St st</c>
</spellresult>

... which you can use with your existing spell checking script such as GoogieSpell that was expecting XML structured data back from Google.

Run in Docker

You can build a Docker image and run it using the included Dockerfile:

$ docker build -t google-spell-pspell .
$ docker run --rm -p 8080:80 google-spell-pspell

and test API using curl:

$ curl -H "Content-Type: text/xml" -X POST -d '<?xml version="1.0" encoding="utf-8" ?><spellrequest><text>Ths is tst</text></spellrequest>' "http://127.0.0.1:8080/tbproxy/spell?lang=en"

Bugs/Suggestions

If you find a bug, or would like to contribute to the project please use the Issue Tracker.

Credits

Mad props to Sabin Iacob (m0n5t3r). Code basically from here, but I removed the Aspell and Google API parts and made it standalone-ready.