Essential Utilities for Modern PHP Development in VS Code.
This extension provides a collection of tools to boost your PHP productivity, focusing on code quality, standard compliance, and ease of use.
Automatically adds declare(strict_types=1); to the top of your PHP files when you save them.
- Ensures type safety in your projects.
- Only adds it if missing (smart check).
- Setting:
phpUtils.autoStrictTypes(Default:true)
Easily create PHP classes, interfaces, traits, and enums from the File Explorer context menu.
- Namespace Resolver: Automatically detects
composer.jsonto generate the correct namespace for your file. - Configurable Menu: Choose to show commands in a submenu or directly in the main context menu.
- Visibility Control: Toggle visibility for Class, Interface, Trait, or Enum commands independently.
- Templates: Generates clean, ready-to-use boilerplate code.
Keep your use statements organized and clean. Runs automatically on save.
- Sorting: Sorts imports alphabetically or by length.
- Grouping: Groups imports from the same namespace.
- Priority: Configurable priority list to keep important namespaces (like
System,App) at the top. - Remove Unused: Automatically detects and removes unused
usestatements. - Settings:
phpUtils.importSorter.onSave: Enable/Disable sorting on save.phpUtils.removeUnusedImports: Enable/Disable unused import removal.phpUtils.importSorter.priority: Array of namespaces to prioritize.phpUtils.importSorter.orderBy:alphaorlength.phpUtils.importSorter.sortDirection:ascordesc.
Complete support for .htaccess files, which is often missing in VS Code.
- Syntax Highlighting: Full colorization for Apache configuration files.
- Formatting: Format your
.htaccessfiles with proper indentation.
A lightweight status bar item that shows helpful statistics about your current selection.
- Displays Line, Column, and Character Count.
- Shows only when you have an active selection.
- Optimized: Uses debounce to prevent performance impact during rapid typing.
| Setting | Default | Description |
|---|---|---|
phpUtils.autoStrictTypes |
true |
Automatically add declare(strict_types=1); on save. |
phpUtils.removeUnusedImports |
true |
Automatically remove unused imports on save. |
phpUtils.importSorter.onSave |
true |
Automatically sort imports on save. |
phpUtils.importSorter.orderBy |
alpha |
Sort order: alpha (Alphabetical) or length. |
phpUtils.importSorter.priority |
["System", "App"] |
Priority list of namespaces. |
phpUtils.importSorter.sortDirection |
asc |
Sort direction: asc or desc. |
phpUtils.importSorter.grouping |
true |
Group imports from the same namespace using braces. |
phpUtils.formatHtaccess.enable |
true |
Enable .htaccess formatting. |
phpUtils.createFile.useSubmenu |
false |
Show file creation commands in a submenu ("New PHP File..."). |
phpUtils.createFile.showClass |
true |
Show "New PHP Class" command. |
phpUtils.createFile.showInterface |
false |
Show "New PHP Interface" command. |
phpUtils.createFile.showTrait |
false |
Show "New PHP Trait" command. |
phpUtils.createFile.showEnum |
false |
Show "New PHP Enum" command. |
- Repository: GitHub
- Issues: Report an Issue
- Publisher: cbkmutlu
This project is licensed under the MIT License.
This extension is a compilation of essential tools, inspired by or directly adapted from the following open-source projects:
- php-auto-strict-types (Apache 2.0)
- vscode-php-create-class (MIT)
- php-import-sorter (MIT)
- vscode-apache (MIT)
- vscode-selection-stats (MIT)
Users can install the extension without the Marketplace:
- Go to the Releases page.
- Download the
.vsixfile from the latest release assets. - Open VS Code.
- Go to the Extensions view (
Ctrl+Shift+X). - Click the ... (three dots) menu at the top-right of the Extensions pane.
- Select "Install from VSIX...".
- Select the downloaded file.
- Reload VS Code.
Important: Since this extension is not on the Marketplace, VS Code will not auto-update it.
To update to a new version:
- Check the Releases page occasionally.
- If there is a new version/tag:
- Download the new
.vsixfile. - Install it using the same steps as above ("Install from VSIX...").
- VS Code will replace the old version with the new one.
- Reload the window.
- Download the new
Enjoy writing better PHP code! 🚀