IDE Support
Learn how to configure your IDE for the best SimpleDTO development experience.
Introduction
Section titled “Introduction”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 / IntelliJ IDEA
Section titled “PhpStorm / IntelliJ IDEA”Installation
Section titled “Installation”PhpStorm has built-in support for PHP 8 attributes and readonly properties.
Configuration
Section titled “Configuration”-
Enable PHP 8.2+ Support
- Go to
Settings→PHP - Set
PHP language levelto8.2or higher
- Go to
-
Install Laravel Idea Plugin (for Laravel projects)
- Go to
Settings→Plugins - Search for “Laravel Idea”
- Install and restart
- Go to
-
Install Symfony Plugin (for Symfony projects)
- Go to
Settings→Plugins - Search for “Symfony Support”
- Install and restart
- Go to
Features
Section titled “Features”Autocompletion
Section titled “Autocompletion”$dto = UserDTO::fromArray([ 'name' => 'John', 'email' => 'john@example.com',]);
// PhpStorm provides autocompletion for:$dto->name // ✅ Autocompletes$dto->email // ✅ Autocompletes$dto->toArray() // ✅ Autocompletes$dto->toJson() // ✅ AutocompletesType Inference
Section titled “Type Inference”// PhpStorm knows the return type$dto = UserDTO::fromArray($data); // UserDTO$array = $dto->toArray(); // array$json = $dto->toJson(); // stringNavigation
Section titled “Navigation”Ctrl+Click(orCmd+Clickon Mac) on property to jump to definitionCtrl+Bto go to declarationCtrl+Alt+Bto go to implementation
Refactoring
Section titled “Refactoring”- Right-click property →
Refactor→Renameto safely rename - Right-click class →
Refactor→Moveto move to different namespace
VS Code
Section titled “VS Code”Installation
Section titled “Installation”Install the following extensions:
-
PHP Intelephense
Terminal window ext install bmewburn.vscode-intelephense-client -
PHP DocBlocker
Terminal window ext install neilbrayfield.php-docblocker -
Laravel Extra Intellisense (for Laravel)
Terminal window ext install amiralizadeh9480.laravel-extra-intellisense
Configuration
Section titled “Configuration”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}Features
Section titled “Features”Autocompletion
Section titled “Autocompletion”Works the same as PhpStorm with Intelephense.
Type Hints
Section titled “Type Hints”Hover over any property or method to see type information.
Go to Definition
Section titled “Go to Definition”F12to go to definitionCtrl+Clickto jump to definition
PHPDoc for Better IDE Support
Section titled “PHPDoc for Better IDE Support”Document Array Types
Section titled “Document Array Types”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, ) {}}Document Return Types
Section titled “Document Return Types”class UserDTO extends SimpleDTO{ // ...
/** * Get user's full name * @return string */ public function getFullName(): string { return $this->firstName . ' ' . $this->lastName; }}Document Complex Types
Section titled “Document Complex Types”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, ) {}}PHPStan Integration
Section titled “PHPStan Integration”Installation
Section titled “Installation”composer require --dev phpstan/phpstanConfiguration
Section titled “Configuration”Create phpstan.neon:
parameters: level: 9 paths: - app - src
# Enable strict rules checkMissingIterableValueType: true checkGenericClassInNonGenericObjectType: trueRun PHPStan
Section titled “Run PHPStan”vendor/bin/phpstan analysePHPStan will validate:
- All properties are typed
- All methods have return types
- No undefined properties
- No type mismatches
Best Practices
Section titled “Best Practices”1. Always Use Type Hints
Section titled “1. Always Use Type Hints”// ✅ Goodpublic readonly string $name;
// ❌ Badpublic readonly $name;2. Document Array Types
Section titled “2. Document Array Types”// ✅ Good/** @var string[] */public readonly array $tags;
// ❌ Badpublic readonly array $tags;3. Use Readonly Properties
Section titled “3. Use Readonly Properties”// ✅ Goodpublic readonly string $name;
// ❌ Badpublic string $name;4. Use PHP 8.2+ Features
Section titled “4. Use PHP 8.2+ Features”// ✅ Good - PHP 8.2+public readonly string $name;
// ❌ Bad - Old style/** @var string */private $name;Troubleshooting
Section titled “Troubleshooting”IDE Not Recognizing Properties
Section titled “IDE Not Recognizing Properties”Problem:
$dto->name // IDE shows "Property not found"Solution:
- Clear IDE cache (PhpStorm:
File→Invalidate Caches) - Rebuild project index
- Check PHP language level is 8.2+
Autocompletion Not Working
Section titled “Autocompletion Not Working”Problem: Autocompletion doesn’t show DTO properties.
Solution:
- Make sure all properties are
public readonly - Check IDE has indexed the project
- Verify PHP version in IDE settings
Type Hints Not Showing
Section titled “Type Hints Not Showing”Problem: Hover doesn’t show type information.
Solution:
- Install PHP Intelephense (VS Code)
- Enable type hints in IDE settings
- Add PHPDoc comments for complex types
See Also
Section titled “See Also”- Creating DTOs - DTO creation guide
- TypeScript Generation - Generate TypeScript types
- Validation - Validation guide