PHP (Composer)
YuktAI for PHP
The yuktishaalaa/yuktai package adds YuktAI to any PHP page in one line: plain PHP, Laravel, WordPress or Symfony. You get the ♿ accessibility widget, the 🛠 page tools and everything in window.yuktai. YuktAI still runs in the visitor's browser. The package only writes the right script tags for you.
- No dependencies, PHP 8.1 or newer.
- No API keys, no server calls, no telemetry.
- Same features and options as the npm and Python packages.
1. Install
composer require yuktishaalaa/yuktaiOn Packagist: packagist.org/packages/yuktishaalaa/yuktai (opens in a new tab)
2. Plain PHP
<?= \Yuktai\Yuktai::script(['position' => 'right', 'showPageTools' => true]) ?>Composer's vendor/autoload.php must be loaded once, as in any Composer project.
3. Laravel
{!! \Yuktai\Yuktai::script(['showPageTools' => true]) !!}Use {!! !!}, not {{ }}: the result is HTML and must not be escaped again.
4. WordPress
add_action('wp_footer', function () {
echo \Yuktai\Yuktai::script(['position' => 'right', 'showPageTools' => true]);
});WordPress loads wp_footer just before </body> on every page.
Options
| Option | What it does |
|---|---|
| version | YuktAI release to load. The package pins a tested release; "latest" follows new releases. |
| position | "left" or "right" |
| primaryColor | Button colour, for example "#0a4a85" |
| title | Title of the settings dialog (Telugu works) |
| showPageTools | Adds the 🛠 page tools button |
| defaultTab | copilot, qa, forms, design, ask or voice |
| voiceLang | Speech language, for example "te-IN" |
| autoFix, showSkipLinks | Accessibility engine options |
| extra | Any other YUKTAI_CONFIG key, as ['key' => value] |
| cdn | "jsdelivr" (default) or "unpkg" |
| defer | true by default |
| nonce | For pages with a Content Security Policy |
Safe by design
Safe JSON
Options are written with JSON_HEX_TAG and JSON_HEX_AMP, so a value like </script> can't break out of the tag.
Typos caught
A wrong value or an unknown option name (like showPagetools) throws InvalidArgumentException instead of being ignored.
CSP ready
Pass 'nonce' => $nonce and both script tags get it. Add cdn.jsdelivr.net to script-src, and 'wasm-unsafe-eval' for the Rust engines.
Tested
PHPUnit tests run on PHP 8.1, 8.2, 8.3 and 8.4 for every push.