Certainly! Here’s a practical guide addressing each of Adam’s points about experimenting with Claude AI for Laravel/PHP development, both inside PHPStorm and via the console.
1. Setting Up and Using Claude in PHPStorm
While there isn’t an official Claude AI plugin for PHPStorm as of now, you can integrate Claude with PHPStorm in two main ways:
-
Using an HTTP Client inside PHPStorm:
PHPStorm has a built-in HTTP client where you can send API requests directly from.httpfiles.-
Obtain your Claude API Key (Anthropic docs).
-
Create a file named
claude.httpin your project root:### Send prompt to Claude API POST https://api.anthropic.com/v1/messages Authorization: Bearer YOUR_CLAUDE_API_KEY Content-Type: application/json X-API-Key: YOUR_CLAUDE_API_KEY { "model": "claude-3-opus-20240229", "messages": [ {"role": "user", "content": "Refactor this PHP function for readability: ..."} ], "max_tokens": 512 } -
Modify the prompt and re-run as needed with
Ctrl+Enter.
-
-
Using AI-powered Plugin Alternatives:
Consider installing generic AI assistant plugins (such as CodeGPT or similar), which can usually be configured with custom endpoints and may work with Claude’s API if you provide the endpoint and key.
2. Calling the Claude API from a CLI Tool or Simple PHP Script
Here’s a simple PHP CLI script using GuzzleHTTP to send prompts to Claude:
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->post('https://api.anthropic.com/v1/messages', [
'headers' => [
'Authorization' => 'Bearer YOUR_CLAUDE_API_KEY',
'Content-Type' => 'application/json',
'X-API-Key' => 'YOUR_CLAUDE_API_KEY',
],
'json' => [
'model' => 'claude-3-opus-20240229',
'messages' => [
['role' => 'user', 'content' => 'Write a Laravel validation rule for an email address.'],
],
'max_tokens' => 512,
],
]);
$body = json_decode($response->getBody(), true);
echo $body['content'][0]['text'] ?? 'No response' . PHP_EOL;
- Make sure you install Guzzle:
composer require guzzlehttp/guzzle
3. Trying it for Refactoring, Writing Tests, or Generating Snippets
You can craft prompts for Claude such as:
- "Rewrite this function to be more readable:"
- "Write a PHPUnit test for the following method:"
- "Generate a Laravel migration for a
poststable"
Claude’s response can be copied back into PHPStorm or your codebase.
4. Trying AI Agents
Most agent-based workflows are still experimental but are beginning to appear in tools like Continue or OpenDevin.
You may clone and run their open source tools, some of which can be configured for Claude API endpoints.
5. Where it Helps and Where it Fails
Helps:
- Quick code generation and boilerplate (migrations, factories, tests)
- Code explanation and exploring unfamiliar code
- Initial refactoring suggestions
Fails:
- Understanding deep business/domain context
- Producing idiomatic PHP/Laravel code in complex scenarios
- Long form code generation (Claude has improved, but context-window/length limits still apply)
Conclusion
A great video could be a simple "screen share" session:
- Crafting prompts, iterating, and copy/pasting results
- Trying a real-world refactor
- Writing and then running tests Claude generates
- Sharing thoughts and examining what Claude gets right vs. wrong
If you'd like prebuilt snippets or a more starter-friendly CLI tool, let me know!