Download the PHP package codechap/yii3-claude-code without Composer

On this page you can find all versions of the php package codechap/yii3-claude-code. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii3-claude-code

Yii3 Claude Code

A Yii3 wrapper for the Claude Code CLI with DI integration, immutable fluent API, and multi-turn conversation support.

Works on Linux, macOS, and Windows. Supports both subscription and API key authentication.

Requirements

Installation

Configuration is auto-loaded via Yii3's config-plugin.

Quick start

Authentication

Subscription (default)

If you're logged in via claude auth login, no extra config is needed. The package unsets ANTHROPIC_API_KEY in the subprocess by default to prevent accidental API charges.

API key

Set the API key in your params to use pay-as-you-go billing instead of a subscription:

Or at runtime:

When an API key is provided, it takes priority — the ANTHROPIC_API_KEY environment variable is set in the subprocess instead of being unset.

Note: With an API key, you are billed per token (pay-as-you-go). With a subscription, usage is included in your monthly plan. Verify your auth method with claude auth status.

Configuration

Override defaults in your application's config/params.php:

Usage

All with* methods are immutable — they return a new instance, leaving the original unchanged.

Model selection

JSON mode

Multi-turn conversations

System prompts

Allowed tools

Working directory

Custom environment variables

Useful when running under a web server where $HOME and $PATH differ from your shell:

Additional CLI flags

Pass arbitrary flags to the claude binary that don't have a dedicated with* method. Three forms are supported:

These are appended after the built-in flags. Run claude --help to see all available flags.

Timeout

Callback

Console command

Requires yiisoft/yii-console.

Use -v for verbose output (session ID and elapsed time).

Response object

Method Returns Description
getResult() string Extracted response text
getRawOutput() string Unprocessed CLI output
getSessionId() ?string Session ID for multi-turn (JSON mode)
getElapsedSeconds() float Wall-clock time in seconds
isJson() bool Whether JSON mode was used
toArray() array Decode result as JSON (throws ParseException on failure)
__toString() string Same as getResult()

Default CLI flags

Every query invokes the claude binary with these flags:

Flag Value Description
--print (always set) Non-interactive mode — sends prompt via stdin and exits. Cannot be disabled.
--output-format text or json Controlled by withJson(). Defaults to text.
--model sonnet Configurable via params (model) or withModel(). Defaults to sonnet.

The resulting command looks like:

Additional flags (--system-prompt, --max-turns, --allowedTools, --resume, --continue) are appended only when their corresponding with* method has been called. For any other CLI flag (e.g. --dangerously-skip-permissions, --effort, --add-dir), use withFlags().

Platform notes

Binary detection

The package auto-detects the claude binary using which (Linux/macOS) or where (Windows). If auto-detection fails — common under web servers with a minimal $PATH — set binaryPath explicitly:

Web server context

When PHP runs under Apache/nginx, the subprocess inherits the web server's environment. This means:

Solutions:

  1. Set binaryPath to the full path of the claude binary
  2. Use envSet to pass the correct HOME (for subscription auth) or use apiKey (for API auth)

Recursion prevention

By default, CLAUDECODE and ANTHROPIC_API_KEY are unset in the subprocess to prevent:

This is configurable via envUnset. When apiKey is set, it overrides the ANTHROPIC_API_KEY unset.

Testing

Integration tests that call the real Claude CLI are automatically skipped if the binary is not available.

License

MIT


All versions of yii3-claude-code with dependencies

PHP Build Version
Package Version
Requires php Version 8.2 - 8.5
symfony/console Version ^6.0 || ^7.0
symfony/process Version ^6.0 || ^7.0
yiisoft/friendly-exception Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package codechap/yii3-claude-code contains the following files

Loading the files please wait ...