Skip to content

IDE Support

Learn how to configure your IDE for the best SimpleDTO development experience.

SimpleDTO provides excellent IDE support with:

  • Full Autocompletion - All properties and methods
  • Type Inference - Automatic type detection
  • PHPDoc Support - Rich documentation
  • Attribute Support - PHP 8 attributes
  • Navigation - Jump to definition
  • Refactoring - Safe renaming and moving

PhpStorm has built-in support for PHP 8 attributes and readonly properties.

  1. Enable PHP 8.2+ Support

    • Go to SettingsPHP
    • Set PHP language level to 8.2 or higher
  2. Install Laravel Idea Plugin (for Laravel projects)

    • Go to SettingsPlugins
    • Search for “Laravel Idea”
    • Install and restart
  3. Install Symfony Plugin (for Symfony projects)

    • Go to SettingsPlugins
    • Search for “Symfony Support”
    • Install and restart
$dto = UserDTO::fromArray([
'name' => 'John',
'email' => 'john@example.com',
]);
// PhpStorm provides autocompletion for:
$dto->name // ✅ Autocompletes
$dto->email // ✅ Autocompletes
$dto->toArray() // ✅ Autocompletes
$dto->toJson() // ✅ Autocompletes
// PhpStorm knows the return type
$dto = UserDTO::fromArray($data); // UserDTO
$array = $dto->toArray(); // array
$json = $dto->toJson(); // string
  • Ctrl+Click (or Cmd+Click on Mac) on property to jump to definition
  • Ctrl+B to go to declaration
  • Ctrl+Alt+B to go to implementation
  • Right-click property → RefactorRename to safely rename
  • Right-click class → RefactorMove to move to different namespace

Install the following extensions:

  1. PHP Intelephense

    Terminal window
    ext install bmewburn.vscode-intelephense-client
  2. PHP DocBlocker

    Terminal window
    ext install neilbrayfield.php-docblocker
  3. Laravel Extra Intellisense (for Laravel)

    Terminal window
    ext install amiralizadeh9480.laravel-extra-intellisense

Create .vscode/settings.json:

{
"php.suggest.basic": false,
"intelephense.stubs": [
"Core",
"PDO",
"SPL",
"standard"
],
"intelephense.environment.phpVersion": "8.2.0",
"intelephense.completion.triggerParameterHints": true,
"intelephense.completion.insertUseDeclaration": true,
"intelephense.format.enable": true
}

Works the same as PhpStorm with Intelephense.

Hover over any property or method to see type information.

  • F12 to go to definition
  • Ctrl+Click to jump to definition
class UserDTO extends SimpleDTO
{
public function __construct(
public readonly int $id,
public readonly string $name,
/** @var string[] */
public readonly array $tags,
/** @var OrderDTO[] */
public readonly array $orders,
/** @var array<string, mixed> */
public readonly array $metadata,
) {}
}
class UserDTO extends SimpleDTO
{
// ...
/**
* Get user's full name
* @return string
*/
public function getFullName(): string
{
return $this->firstName . ' ' . $this->lastName;
}
}
class OrderDTO extends SimpleDTO
{
public function __construct(
public readonly int $id,
/** @var array<int, ProductDTO> */
public readonly array $products,
/** @var array{total: float, tax: float, shipping: float} */
public readonly array $pricing,
) {}
}
Terminal window
composer require --dev phpstan/phpstan

Create phpstan.neon:

parameters:
level: 9
paths:
- app
- src
# Enable strict rules
checkMissingIterableValueType: true
checkGenericClassInNonGenericObjectType: true
Terminal window
vendor/bin/phpstan analyse

PHPStan will validate:

  • All properties are typed
  • All methods have return types
  • No undefined properties
  • No type mismatches
// ✅ Good
public readonly string $name;
// ❌ Bad
public readonly $name;
// ✅ Good
/** @var string[] */
public readonly array $tags;
// ❌ Bad
public readonly array $tags;
// ✅ Good
public readonly string $name;
// ❌ Bad
public string $name;
// ✅ Good - PHP 8.2+
public readonly string $name;
// ❌ Bad - Old style
/** @var string */
private $name;

Problem:

$dto->name // IDE shows "Property not found"

Solution:

  1. Clear IDE cache (PhpStorm: FileInvalidate Caches)
  2. Rebuild project index
  3. Check PHP language level is 8.2+

Problem: Autocompletion doesn’t show DTO properties.

Solution:

  1. Make sure all properties are public readonly
  2. Check IDE has indexed the project
  3. Verify PHP version in IDE settings

Problem: Hover doesn’t show type information.

Solution:

  1. Install PHP Intelephense (VS Code)
  2. Enable type hints in IDE settings
  3. Add PHPDoc comments for complex types