WordPress / WordPress/php-ai-client

cli.php: missing provider registration and .env loading causes "Provider not registered" error

Open Beginner friendly
#223 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
308
Forks
84
Avg merge
7d 21h
Merged PRs (30d)
2

Description

Description:

Bug Report

Summary

On running cli.php with any provider (e.g. --providerId=google) always fails with:

[ERROR] Invalid arguments while trying to set up prompt builder: Provider not registered: google

Cause

This happens even when the correct API key is set in .env and the provider packages (wordpress/google-ai-provider, wordpress/openai-ai-provider, wordpress/anthropic-ai-provider) are installed as dev dependencies.

cli.php is missing two bootstrapping steps that the integration test suite handles in tests/integration/bootstrap.php:

  1. Loading .env API keys in .env are never read into the environment, so getenv() calls inside providers return nothing.
  2. Registering providers — Provider classes (e.g. GoogleProvider) are never registered with the ProviderRegistry, so the registry has no providers to resolve by ID.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare cli.php with tests/integration/bootstrap.php, starting with the two bootstrapping steps identified in the issue: loading .env values and registering provider classes with ProviderRegistry. Run cli.php with a provider such as google and verify that the provider resolves and API-key loading no longer fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.