Bundles the wordpress/php-ai-client library into WordPress Core at src/wp-includes/php-ai-client/.
The installer fetches the package, scopes its third-party dependencies (Http*, Psr*, etc.) under WordPress\AiClientDependencies\* using PHP-Scoper to avoid conflicts with plugins, reorganizes the files into a namespace-based layout, and generates a manual autoloader.
- PHP
- Composer
- Git
Run from the WordPress development repository root:
# Install a specific release version
bash tools/php-ai-client/installer.sh --version=1.0.0
# Install from a branch
bash tools/php-ai-client/installer.sh --branch=mainYou must specify either --version or --branch (not both).
- Clones the package from GitHub (shallow clone of the specified ref).
- Runs
composer install --no-devto fetch dependencies. - Downloads PHP-Scoper and scopes all dependency namespaces to
WordPress\AiClientDependencies\*. - Reorganizes scoped dependencies from Composer's
vendor/layout into a namespace-basedthird-party/directory. - Removes unused files (async/promise support, deprecated discovery classes, etc.).
- Generates
autoload.phpwith a PSR-4 autoloader. - Validates the output.
src/wp-includes/php-ai-client/
├── autoload.php # Generated autoloader
├── src/ # AI Client source (WordPress\AiClient\*)
└── third-party/ # Scoped dependencies (WordPress\AiClientDependencies\*)
├── Http/
└── Psr/
scoper.inc.php— PHP-Scoper configuration. Defines the scoping prefix, excludes the AI Client's own namespace, and patches php-http/discovery to preserve references to external HTTP implementations.reorganize.php— Reads Composer'sinstalled.jsonand copies scoped vendor files into a flat namespace-based directory structure.