PHP Serialized String Formatter is a Visual Studio Code extension designed to enhance the readability of PHP serialized strings. It automatically formats serialized data by adding indentation and line breaks, making it easier to debug and maintain serialized structures within your PHP projects.
Features
Automatic Formatting: Format selected serialized strings or entire documents with a simple command.
Customizable Keybinding: Trigger formatting using a keyboard shortcut.
Language Support: Optimized for PHP and plaintext files.
Handles Escaped Characters: Properly manages escaped quotes and other serialized data nuances.
User-Friendly Notifications: Receive confirmation messages upon successful formatting or error alerts for invalid serialized strings.
Installation
You can install the extension directly from the Visual Studio Code Marketplace or manually via the .vsix file.
Install from Marketplace
Open Visual Studio Code.
Navigate to the Extensions view by clicking the Extensions icon in the Activity Bar or pressing Ctrl+Shift+X (Cmd+Shift+X on macOS).
Search for "PHP Serialized String Formatter".
Click Install on the extension by twindai.
Install from VSIX
Download the .vsix file from the releases page or your project's repository.
Open Visual Studio Code.
Navigate to the Extensions view.
Click on the three-dot menu (...) in the top-right corner.
Select Install from VSIX....
Browse and select the downloaded .vsix file.
Reload VSCode when prompted.
Usage
Formatting Serialized Strings
You can format PHP serialized strings either by selecting the specific portion of text or by formatting the entire document.
Select the Serialized String:
Highlight the serialized string you want to format.
Press the formatting keybinding (Ctrl+Alt+F).
OR
Format Entire Document:
Ensure no text is selected.
Trigger the formatter using the keybinding or Command Palette.
Using the Command Palette
Open the Command Palette by pressing Ctrl+Shift+P (Cmd+Shift+P on macOS).
Type Format PHP Serialized String and press Enter.
Keybindings
By default, the extension uses the following keybinding:
Format PHP Serialized String:Ctrl+Alt+F (Windows/Linux) | Shift+Option+F (macOS)
You can customize the keybinding by modifying your VSCode keyboard shortcuts:
Open Keyboard Shortcuts by pressing Ctrl+K Ctrl+S (Cmd+K Cmd+S on macOS).
Search for Format PHP Serialized String.
Click on the pencil icon to assign a new keybinding.