Create a PHPstorm plugin
Hello,
I'm trying to create a PHPStorm plugin with Kotlin (I would like to learn Kotlin, and the best way to do is to create a real project) but I don't know how to run a PHPStorm sandbox instead of Intellij IDEA.
I followed this tutorial : https://www.jetbrains.org/intellij/sdk/docs/tutorials/build_system/prerequisites.html
To run the plugin with kotlin I have changed the build.gradle file like this:
plugins {
id 'org.jetbrains.intellij' version '0.3.12'
id 'org.jetbrains.kotlin.jvm' version '1.3.10'
}
repositories {
mavenCentral()
}
group 'fr.example'
version '1.0-SNAPSHOT'
intellij {
version '2018.3'
pluginName 'Test'
}
patchPluginXml {
changeNotes """
Add change notes here.<br>
<em>most HTML tags may be used</em>"""
}
and the plugin.xml is:
<idea-plugin>
<id>fr.example.test</id>
<name>Test</name>
<vendor email="support@example.fr" url="https://example.fr">Example</vendor>
<description>Plugin description</description>
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<!-- uncomment to enable plugin in all products
<depends>com.intellij.modules.lang</depends>
-->
<depends>com.jetbrains.php</depends>
<depends>com.intellij.modules.platform</depends>
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
</extensions>
<actions>
<group id="Example.SampleMenu" text="Greeting" description="Greeting menu">
<action id="Example.Textboxes" class="HelloAction" text="Hello" description="Says hello"/>
<add-to-group group-id="MainMenu" anchor="last"/>
<separator/>
</group>
</actions>
</idea-plugin>
The first issue is the dependency com.jetbrains.php cannot be resolved in the xml file. I don't know why.
Even if the issue is resolved, I still don't know how to run PHPStorm in a gradle task.
Could you please tell me how to create a PHPStorm plugin and running an instance of PHPStorm instead of Intellij CE?
I'm using the last version of Intellij CE and I have PHPStorm installed with a licence.
请先登录再写评论。
Hi,
> The first issue is the dependency com.jetbrains.php cannot be resolved in the xml file. I don't know why.
You need to add dependency on php plugin. See the configuration section for instructions: https://github.com/JetBrains/gradle-intellij-plugin/#setup-dsl
Note that the plugin is not compatible with IntelliJ CE, you should you IU instead (see the same link as above)
> Even if the issue is resolved, I still don't know how to run PHPStorm in a gradle task.
Generally, you don't need this, develop it for IntelliJ UI with Php plugin and it will work in PhpStorm. If you still need a Php storm, you can use the local IDE installation for running, see `alternativeIdePath` option in the link above.
Thank you for the reply.
I need to have this?
So I need a licence for IntelliJ IU to create a PHPStorm plugin? :/
I have 30 days to learn kotlin and create my plugin x)
> I need to have this?
yes
> So I need a licence for IntelliJ IU to create a PHPStorm plugin? :/
No, you can develop the plugin in Community Edition. You just need to use UI for building your plugin:
```
intellij {
version 'IU-2018.3'
}
```
My new gradle script is:
In the plugin.xml the dependency com.jetbrains.php is still not resolved. I missing something?
When the IDE is running, the PHP plugin is not installed, it's normal?
Even if I enable it, it doesn't work. Each time I run runIde the PHP plugin is not installed in my sandbox.
> When the IDE is running, the PHP plugin is not installed, it's normal?
You didn't set the version of the php plugin. Please see the README to learn how to set a dependency.
I wonder how :runIde works for you with this configuration. How do you run the task exactly? Don't you have any warning messages in starting logs?
If I set the version like this plugins ['com.jetbrains.php:183.4588.24'] it will works everytime I run the sandbox?
I run it from the Tool window: (the only warning I have is: OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=250m; support was removed in 8.0)
> If I set the version like this plugins ['com.jetbrains.php:183.4588.24'] it will works everytime I run the sandbox?
If you do not set the version it won't work even a single time, so I'm not sure what you're asking about.
Even if I set the version for PHP plugin in the gradle task, the sandbox don't have the PHP plugin installed by default where the IDE is running.
I would like to have the php plugin installed each time I run the "runIde" gradle task
Attach the building logs and logs of ide you run (the latter located in build/idea-sandbox/system/idea.log)
My idea.log after only one run.
what about building logs?
Which location?
In the sandbox/system/log I have only the idea.log
they are in your Run output
up-to-date doesn't say too much, run clean first, please.
what if you remove that line?
I have cleaned with the clean task.
Still the same error even without the sandboxDirectory, the PHP plugin is not loaded.
I see. Do this:
instead of
It's works :)
I have changed the version to 183.4284.150 because the latest is for the RC IU.
How to use the latest IntelliJ IDEA stable release instead of RC?
PS: All the docs is here? https://www.jetbrains.org/intellij/sdk/docs/welcome.html (API too?)
Good to hear it works.
You can find all available versions here: https://www.jetbrains.com/intellij-repository/releases and here: https://www.jetbrains.com/intellij-repository/snapshots.
> PS: All the docs is here?
All that we have. We do not describe API in external documentation.
Thank you for the links.
By the way, do you have a doc or a list about the group-id?
For example I would like to add item in the new popup menu, the right click in editor. It's difficult to find resources about that.
Code is the best resources for this. Most of group-ids you can find in PlatformActions.xml, RishPlatformActions.xml and LangAction.xml files.
Thanks :)
It's possible to add an item to NewGroup group-id? I would like to add an action in NewGroup but at the end of the PHP section if it's possible.
It seems to be a solution, but to place the item after PHP section what is the relative-to-action?
The PHP plugin is not open source so, I don't know what is the group name for this section.
For example I have: By the way, the separator doesn't work here
I just found that: https://github.com/JetBrains/intellij-community/blob/master/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
It's helping, but I don't know if it's possible to add an item just after PHP Class
> It's possible to add an item to NewGroup group-id?
> The PHP plugin is not open source so, I don't know what is the group name for this section.
It doesn't matter, you still can see all resources and decompiled classes in External LIbraries node.
> For example I have: By the way, the separator doesn't work here
How do you expect it should work here? It's located on the very first place in the group.
Thank you again!
Small question here, how to get the PHP Class native icon used by IntelliJ or PHPStorm in the "NewGroup"? I need to copy/paste the original .png in my plugin?
I have created a class in a package icons like this:
But in my plugin.xml the ZendGeneratorIcon.ZEND_GENERATOR_ACTION doesn't work (cannot resolve icon).
I'm trying to do the same thing as the symfony plugin (https://github.com/Haehnchen/idea-php-symfony2-plugin/blob/master/src/main/resources/META-INF/plugin.xml)
I'm still stuck with the separator.
I even try to create a group with only a separator with add-to-group to my group but it doesn't work.
Even the existing plugins can't help in my case.
> Small question here, how to get the PHP Class native icon used by IntelliJ or PHPStorm in the "NewGroup"?
> I even try to create a group with only a separator with add-to-group to my group but it doesn't work.
You still didn't describe what're you doing, expected behavior and actual behavior, with code and screenshots. I cannot help you with "something doesn't work" complain.
In the new group I would like to have something like that:
File
New stracth file
Directory
PHP file
PHP class
SEPARATOR (from my plugin)
Zend (my group)
My group looks like this:
What about custom icon class instead of hard coded the path in icon attribute?
I don’t see any separators in your code. Also you have a pop up group and define separator inside it, why it should appear on the parent New file popup?
> what about custom icon
See previous comment