Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>PHP CompanionNew to Visual Studio Code? Get it now.
PHP Companion

PHP Companion

Fred Blanc

|
15,433 installs
| (3) | Free
Create new PHP class, run tests, insert namespace, ...
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PHP Companion

This extension allows to easily create new PHP class, run test, insert namespace, etc.

Features

  • Create PHP class file content
  • Read Namespace from composer.json
  • Insert namespace for a file
  • Add extends PHPUnit TestCase to classes wich names ends with "Test"
  • Declare an interface if name ends with "Interface"
  • Add command and Keybindings to easily run tests
  • Open tests logs in a virtual document

Create new PHP files

From explorer, right click on a folder and select "New PHP Class"

New PHP Class screenshot

See FAQ to read more about generated namespace

Insert namespace in PHP files

Select text or move cursor to the desired position and right click, then choose "Insert namespace" menu item

Insert namespace screenshot

Snippets

Type con to generate class constructor :

public function __construct(Type $param)
{
    $this->param = $param;
}

Type prop to generate class property :

private Type $;

Type fun to generate class method :

public function functionName(Type $param): void
{
    
}

Type cop to generate class constructor with property (php >= 8.0 required) :

public function __construct(
    private Type $param
) {
    
}

Easily run tests

Hit F9 (default keybindings) or select the command to run tests

commands screenshot

Tests will be executed, and results will be shown in statusbar

Status bar screenshot

Click "Open tests logs" and see what happened

Tests logs screenshot

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft