Phpstorm

From G1Joshi/Agent-Skills · View interactive version

Phpstorm is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert PhpStorm assistance covering PHP language tooling, Laravel/Symfony integrations, Xdebug setup, Composer dependency inspection, and database tooling. Use when configuring Xdebug remote debugging, setting up PHPStan/Psalm inspections, optimizing IDE performance, or debugging PHP applications.

How to use this skill

Skill file

PhpStorm

PhpStorm is essential for modern PHP. It understands Laravel Facades, Symfony Dependency Injection, and Doctrine queries.

When to Use

Quick Start

1. Docker Xdebug Configuration for PhpStorm

; php.ini / 99-xdebug.ini
[xdebug]
zend_extension=xdebug.so
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
xdebug.idekey=PHPSTORM

2. Configure PHP CLI Interpreter

Core Concepts

Advanced Xdebug 3 Configuration

Setting up php.ini and configuring PhpStorm for zero-config Xdebug step debugging:

; php.ini (PHP 8.3 / 8.4)
[xdebug]
zend_extension = xdebug.so
xdebug.mode = debug,develop
xdebug.start_with_request = yes
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
xdebug.idekey = PHPSTORM
xdebug.log = /tmp/xdebug.log

Connecting PhpStorm to Docker Container mapping in .idea/php.xml:

<project version="4">
  <component name="PhpDebugGeneral" listening_started="true" />
  <component name="PhpServers">
    <servers>
      <server host="localhost" id="docker_server" name="docker_server" port="8080" use_path_mappings="true">
        <path_mappings>
          <mapping local-root="$PROJECT_DIR$" remote-root="/var/www/html" />
        </path_mappings>
      </server>
    </servers>
  </component>
</project>

Framework Metadata Enhancement (`.phpstorm.meta.php`)

Providing PhpStorm with container return types and factory inference:

<?php
// .phpstorm.meta.php
namespace PHPSTORM_META {
    override(\Illuminate\Contracts\Container\Container::make(0), map([
        '' => '@',
    ]));
    override(\app(0), map([
        '' => '@',
    ]));
}

Static Analysis Automation (PHPStan & Pint)

Configuring Composer scripts and real-time inspections:

{
  "scripts": {
    "lint": "pint --test",
    "lint:fix": "pint",
    "analyse": "phpstan analyse --level=9 --memory-limit=1G"
  }
}

Common Patterns

Path Mapping for Dockerized Projects

Problem: Breakpoints inside Docker containers are not hit because local and container filesystem paths differ.

Solution:

# .idea/php.xml (Docker Xdebug Path Mapping)
[Server]
Host=localhost
Port=8080
UsePathMappings=true
LocalPath=/Users/username/Code/my-project
RemotePath=/var/www/html

Static Analysis (PHPStan / Psalm) Integration

Problem: Enforce strict type checks inside editor inspection gutters before code commit.

Solution: Enable PHPStan in PhpStorm settings.

# phpstan.neon
parameters:
    level: 8
    paths:
        - app
        - tests
    checkMissingIterableValueType: false

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| ----------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |

| Xdebug breakpoint ignored / not triggered | xdebug.client_host wrong or firewall blocking port 9003 | Use host.docker.internal on Docker for Mac/Windows, verify IDE listener is enabled (green telephone icon). |

| High memory usage or slow indexing | Indexing large directories like storage/, var/, or generated caches | Right-click directory > Mark Directory as > Excluded. |

| Laravel facade autocompletion broken | PhpStorm does not know dynamic magic methods on facades | Install and run barryvdh/laravel-ide-helper: php artisan ide-helper:generate. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.