Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>PHP Class GeneratorNew to Visual Studio Code? Get it now.
PHP Class Generator

PHP Class Generator

damianbal

|
114,437 installs
| (6) | Free
Generate class and namespace out of file path
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

PHP Class Generator

Download extension from VS Code Marketplace

Simple extenstion for PHP which will generate PHP class out of file, for example if file is in src/MyApp/Services/BlaService.php

The result would be

<?php

namespace YourVendorIfSet\MyApp\Services; // read Extension Settings 

class BlaService
{
}

Note: Make sure that your source code is under src directory, or app if it is Laravel.

Animated examples

Insert namespace Generate PHP class Generate PHP interface

Features

  • Insert PS4 Namespace out of file path
  • Generate PHP class matching file path
  • Generate PHP interface matching file path
  • Generate PHP trait matching file path
  • Works with Laravel

Commands

  • Insert PHP Namespace - inserts only namespace
  • Generate PHP Class - generates what is above in example
  • Generate PHP Interface - same as above but instead of class it will be interface
  • Generate PHP Trait - generates PHP trait

Extension Settings

This extension contributes the following settings:

  • phpclassgen.vendor: set it to your name, or leave it blank if you do not want any prefix in namespaces.

Enjoy!

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