Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>PHP Better RefactorsNew to Visual Studio Code? Get it now.
PHP Better Refactors

PHP Better Refactors

kevinvargasl

|
1 install
| (1) | Free
PSR-4-aware PHP refactoring: automatic class/file/namespace, properties and methods renaming and cross-project reference updates
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Logo
PHP Better Refactors

PSR-4-aware PHP refactoring for VS Code. Automatically updates class names, namespaces, and all references across your project when you rename or move files. Includes classes, interfaces, traits and enums.

Features

  • Rename Symbol for class names, methods, and properties with cross-project reference updates
  • File rename → Class rename — renaming User.php to Account.php renames class User to class Account and updates all references
  • File move → Namespace update — moving a file to a different folder updates the namespace declaration and cross-project reference updates
  • Import class quick fix — suggests adding use statements for unresolved class references
  • Updates all use statements, type hints, new, extends, implements, ::class, catch, instanceof, attributes, and more
  • Handles group use statements, aliased imports, and fully-qualified references
  • PSR-4 namespace resolution from composer.json

Demos

Rename Symbol

Right-click a class name, method, or property and select Rename Symbol. The declaration, file, and all references across the project are updated.

Rename Symbol

File Rename

Rename a .php file in the explorer — the class declaration and all references are updated automatically.

File Rename

File Move

Move a file to a different folder — the namespace declaration and all references are updated.

File Move

Import Class

Use a class without a use statement and get a quick fix to import it.

Import Class

Installation

Marketplace

Visit the extension page and press install.

From .vsix

  • Download the .vsix file from the latest release
  • Open VS Code
  • Press Ctrl+Shift+P and run Extensions: Install from VSIX...
  • Select the .vsix file

Settings

All settings are under phpBetterRefactors.* in VS Code settings.

Setting Type Default Description
phpBetterRefactors.enableAutoRename boolean true Automatically rename class when file is renamed
phpBetterRefactors.enableAutoNamespace boolean true Automatically update namespace when file is moved
phpBetterRefactors.excludePatterns string[] ["**/vendor/**", "**/node_modules/**"] Patterns for files/folders to exclude from reference scanning

Commands

Command Description
PHP Better Refactors: Rebuild Index Re-scan all PHP files and rebuild the reference index

Requirements

  • VS Code 1.85.0 or later
  • A composer.json file in the workspace (for PSR-4 namespace resolution)
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft