A PhpStorm plugin that converts JSON to PHP array and PHP array to JSON.
The plugin provides a tool window for JSON input and output, allowing easy bidirectional conversion and replacement within the editor.
✅ Tested on:
- Java 21
- PhpStorm 2024.2.5
Ensure that Java 21 is installed. If not, install it via Homebrew (macOS) or manually.
/usr/libexec/java_home -VIf Java 21 is missing, install it:
brew install openjdk@21
sudo ln -sfn /opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-21.jdksudo apt update
sudo apt install openjdk-21-jdkscoop install openjdk21Ensure Java 21 is active:
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
export PATH="$JAVA_HOME/bin:$PATH"
java -versionEnsure that Gradle is installed:
brew install gradlesudo apt install gradlescoop install gradleVerify the installation:
gradle -vgit clone git@github.com:AUnhurian/json2array-plugin.git
cd json2php-pluginRun the following command to generate the Gradle wrapper:
gradle wrapperThis will create the ./gradlew script, ensuring the correct Gradle version is used.
./gradlew cleanRemoves the build/ directory and resets the project.
./gradlew buildPluginCompiles the plugin and creates a distributable .zip file inside the build/distributions/ folder.
./gradlew testRuns JUnit 5 tests to validate JSON-to-PHP array conversion.
./gradlew runIdeStarts a development instance of PhpStorm (2024.2.5) with the plugin loaded for testing.
- Select JSON text in PhpStorm.
- Right-click and choose "Convert JSON to PHP Array".
- The tool window opens with:
- Input JSON
- Converted PHP array
- Replace in Editor button
- Modify or copy the output as needed.
- Open the "Json to PHP Array" tool window.
- Paste your PHP array in the output field (or convert JSON first).
- Click "Convert to JSON" button.
- The JSON will appear in the input field.
- Use "Replace in Editor" to replace selected text with JSON.
- ✅ Bidirectional conversion: JSON ↔ PHP Array
- ✅ Nested objects and arrays support
- ✅ Boolean, null, and numeric values handling
- ✅ String escaping for special characters
- ✅ Quick conversion via context menu
- ✅ Tool window for complex conversions
- ✅ Replace in editor functionality
- Fork the repository.
- Create a new branch (
feature/new-functionality). - Commit changes and submit a pull request.
MIT License