Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Anthropic Php

Anthropic Php Laravel Package

mozex/anthropic-php

Unofficial PHP client for Anthropic’s Claude API. Send messages, build prompts, and work with streaming responses using a simple, framework-friendly interface. Great for adding Claude-powered chat and automation to Laravel or any PHP app.

Deep Wiki
Context7

mozex/anthropic-php is a lightweight PHP client for the Anthropic API, designed to make integrating Claude into Laravel or any PHP app straightforward. It offers a clean, developer-friendly interface for sending prompts and handling responses with minimal boilerplate.

Built with practical defaults and extensibility in mind, it helps you ship reliable AI features quickly while keeping your codebase maintainable.

  • Simple API client for Claude messages/completions
  • Easy authentication & configuration (API keys, headers)
  • Support for streaming and standard responses
  • Typed/structured request & response handling
  • Works well in Laravel and plain PHP projects
Frequently asked questions about Anthropic Php
How do I install mozex/anthropic-php in a Laravel project?
Use Composer to install the package with `composer require mozex/anthropic-php`. The package is designed to work with Laravel’s service container, so you can bind it in `config/app.php` or use it directly in controllers/services. No additional Laravel-specific setup is required beyond standard Composer dependencies.
Does this package support Laravel’s HTTP client for API requests?
The package description suggests it’s built for simplicity and likely uses PHP’s native HTTP clients or a lightweight wrapper, but without access to the source code, we can’t confirm direct Laravel HTTP client integration. Check the package’s documentation or source for specifics on underlying HTTP handling.
Can I use this for streaming responses from Claude?
Yes, the package explicitly mentions support for streaming responses, making it ideal for real-time chat or interactive AI features in Laravel. Streaming is typically handled via event listeners or callbacks, so ensure your Laravel app can process async responses efficiently.
What Laravel versions does mozex/anthropic-php support?
The package is designed for modern Laravel (likely 8.x+) and plain PHP, but version compatibility isn’t specified in the provided details. Always check the package’s documentation or composer.json for explicit Laravel version requirements before integrating.
How do I handle API authentication with Anthropic’s keys?
The package includes built-in support for API key authentication, likely via headers or environment variables. You’ll typically configure the key in your Laravel `.env` file (e.g., `ANTHROPIC_API_KEY`) and pass it during client initialization. Refer to the package’s docs for exact configuration steps.
Is this package suitable for production use in Laravel?
While the package is designed for reliability, its production-readiness depends on untested factors like error handling, retries, and rate limiting. Since the repository is unknown, verify its maintenance status and community adoption before deploying critical AI features. Consider adding custom middleware for logging or retries.
Can I use this package outside Laravel (e.g., in plain PHP)?
Yes, the package is framework-agnostic and works in plain PHP projects. It’s built for simplicity, so you can initialize the client and send requests without Laravel-specific dependencies. However, Laravel features like service binding won’t apply.
Are there alternatives to mozex/anthropic-php for Laravel?
Yes, alternatives include the official Anthropic PHP SDK (if available) or community packages like `guzzlehttp/guzzle` with custom wrappers. Compare features like streaming support, typing, and Laravel integration before choosing. Mozex’s package stands out for its Laravel-friendly design but lacks public verification.
How do I test this package in Laravel unit tests?
Mock the Anthropic API responses using Laravel’s HTTP testing helpers or PHPUnit’s HTTP client. Since the package likely uses a simple interface, you can stub the client’s methods (e.g., `sendMessage()`) and assert responses. Check if the package provides test utilities or examples for mocking.
What’s the best way to structure prompts with this package?
The package supports typed/structured request handling, so define prompts as arrays or objects with clear keys (e.g., `role`, `content`). For complex prompts, consider using Laravel’s `config()` or a dedicated service class to manage templates. Streaming responses may require additional handling for dynamic content.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport