β AI in PhpStorm: a GPT that helps you
docs: English JsonRpcBundle docs, REST and MCP Bundle sections, package cards
en/articles/from-tg/tools/phpstorm-ai.md
new file +88
β0
1
+
# AI in PhpStorm: a GPT that helps you
2
+
3
+
JetBrains has long been making one of the best environments for PHP development, but with the arrival of AI Assistant the IDE has reached a new level. In short, it's ChatGPT built right into PhpStorm that "knows" where you are and what you're working on (provided you give it access to your code).
4
+
5
+
I tried it in my work and really liked what I got out of it, but let's take things in order.
6
+
7
+
:::warning subtitle="A bit of a cold shower"
8
+
It's a paid feature. And no, it doesn't plug into the ChatGPT Plus or API subscription you're already paying for.
9
+
10
+
JetBrains sells it as a separate service, so if you want GPT right in your editor you'll have to pay an extra $10 a month, or use the free plan with its limits.
11
+
12
+
Spoiler: *for the most part, the free plan's limits are enough for everyday work β as long as you can still write code yourself.*
13
+
:::
14
+
15
+
## What can AI Assistant in PhpStorm do?
16
+
17
+
### 1. Explaining code
18
+
19
+
Select a fragment β `Alt+Enter` β `Explain code with AI`. The AI briefly explains what's going on here (taking the context into account).
20
+
21
+
### 2. Generating tests
22
+
23
+
From the same menu you can generate PHPUnit tests. Sometimes a bit raw, but as a template β very handy.
24
+
25
+
### 3. Writing docblocks and comments
26
+
27
+
Select a method and the AI describes what the method is, what parameters it takes and what it returns. All in the familiar `@param`, `@return` format.
28
+
29
+
### 4. Refactor this with AI
30
+
31
+
You can delegate improving a method, renaming variables, extracting dependencies β the AI will suggest options.
32
+
33
+

34
+
35
+
*A refactoring suggestion in the chat. Screenshot from the [JetBrains documentation](https://www.jetbrains.com/help/ai-assistant/ai-chat.html) (IntelliJ IDEA; PhpStorm has the same interface)*
36
+
37
+
### 5. Answering questions
38
+
39
+
A built-in chat that remembers the file you're working on. For example:
40
+
41
+
> "What does this code do?"
42
+
> "How can I reduce the algorithm's complexity here?"
43
+
> "Why is it better not to use isset here?"
44
+
45
+

46
+
47
+
*Elements of the AI Chat window. Screenshot from the [JetBrains documentation](https://www.jetbrains.com/help/ai-assistant/ai-chat.html)*
48
+
49
+
## Usage example
50
+
51
+
```php
52
+
class DiscountCalculator
53
+
{
54
+
public function calculate(float $price, int $percentage): float
55
+
{
56
+
return $price * (1 - $percentage / 100);
57
+
}
58
+
}
59
+
```
60
+
61
+
Select the method β `Explain code with AI`
62
+
63
+
> "This method calculates a percentage discount and returns the new price. If you pass 100 UAH and 20%, the method returns 80."
64
+
65
+
or select the method β `Alt+Enter` β `Generate Unit Tests`
66
+
67
+
```php
68
+
public function testCalculate(): void
69
+
{
70
+
$calc = new DiscountCalculator();
71
+
$this->assertSame(80.0, $calc->calculate(100.0, 20));
72
+
}
73
+
```
74
+
75
+
## Why do you need it?
76
+
77
+
- Better understanding of code for those who don't read it well yet.
78
+
- Getting rid of routine work.
79
+
- Quick feedback right in the editor, with no switching to the browser when questions come up.
80
+
81
+
## Conclusion
82
+
83
+
> AI Assistant in PhpStorm is a genuinely convenient tool that saves me about an hour a day.
84
+
> It helps me work more confidently with legacy code, other people's repositories, or when you just want to give your head a little rest.
85
+
86
+
---
87
+
88
+
*First published in Ukrainian in the Telegram channel [βCreated to dieβ](https://t.me/php_while_true/36) on June 23, 2025.*