Skip to content

Commit 6fa12cb

Browse files
committed
chore: adds php ai client tool readme
1 parent b5baa00 commit 6fa12cb

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

tools/php-ai-client/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# PHP AI Client Installer
2+
3+
Bundles the [wordpress/php-ai-client](https://github.com/WordPress/php-ai-client) library into WordPress Core at `src/wp-includes/php-ai-client/`.
4+
5+
The installer fetches the package, scopes its third-party dependencies (Http\*, Psr\*, etc.) under `WordPress\AiClientDependencies\*` using [PHP-Scoper](https://github.com/humbug/php-scoper) to avoid conflicts with plugins, reorganizes the files into a namespace-based layout, and generates a manual autoloader.
6+
7+
## Prerequisites
8+
9+
- PHP
10+
- Composer
11+
- Git
12+
13+
## Usage
14+
15+
Run from the WordPress development repository root:
16+
17+
```bash
18+
# Install a specific release version
19+
bash tools/php-ai-client/installer.sh --version=1.0.0
20+
21+
# Install from a branch
22+
bash tools/php-ai-client/installer.sh --branch=main
23+
```
24+
25+
You must specify either `--version` or `--branch` (not both).
26+
27+
## What It Does
28+
29+
1. Clones the package from GitHub (shallow clone of the specified ref).
30+
2. Runs `composer install --no-dev` to fetch dependencies.
31+
3. Downloads PHP-Scoper and scopes all dependency namespaces to `WordPress\AiClientDependencies\*`.
32+
4. Reorganizes scoped dependencies from Composer's `vendor/` layout into a namespace-based `third-party/` directory.
33+
5. Removes unused files (async/promise support, deprecated discovery classes, etc.).
34+
6. Generates `autoload.php` with a PSR-4 autoloader.
35+
7. Validates the output.
36+
37+
## Output Structure
38+
39+
```
40+
src/wp-includes/php-ai-client/
41+
├── autoload.php # Generated autoloader
42+
├── src/ # AI Client source (WordPress\AiClient\*)
43+
└── third-party/ # Scoped dependencies (WordPress\AiClientDependencies\*)
44+
├── Http/
45+
└── Psr/
46+
```
47+
48+
## Support Files
49+
50+
- **`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.
51+
- **`reorganize.php`** — Reads Composer's `installed.json` and copies scoped vendor files into a flat namespace-based directory structure.

0 commit comments

Comments
 (0)