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.

1
40 comments
Avatar
Permanently deleted user

My code looks like this:

<group id="Zend.Separator">
<separator/>
<add-to-group group-id="Zend.NewGroup" anchor="first"/>
</group>

<group id="Zend.NewGroup" text="Zend Generator" popup="true" icon="/icons/zend_framework_action.png" class="fr.wixiweb.idea.zendgenerator.action.ZendGeneratorGroupActionGroup">
<action class="fr.wixiweb.idea.zendgenerator.action.query.CreateQueryAction"
id="fr.wixiweb.idea.zendgenerator.action.query.CreateQueryAction"
text="Create query" />
<add-to-group group-id="NewGroup" anchor="after" relative-to-action="PhpNewGroup"/>
</group>

I would like to separate my popup entry between PHP Class and MyPluginName Popup

For example we can take the refactor popup in NewGroup

- SEPARATOR

- Refactor > Some action list

- SEPARATOR

 

0

But you add your separator group inside zend group, why do you expect to see it in NewGroup?

0
Avatar
Permanently deleted user

I try to understand how it's work.

I try a lot of thing but nothing seems logic to me.

How can I achieve this?

0

I ask questions to let you understand how it works, but you kind of ignore them. Ok, here is the pseudocode for your case:

group zendgroup
separator
add-to-group NewGroup

group ZendPopupGroup
action
add-to-group zendgroup

The logic behind that is to put group with separator and your popup into newgroup. You code did different thing, it put separator into popup and put popup in newgroup

0
Avatar
Permanently deleted user

You tell me to put a group inside other group? For me, it's logical to have a parent group at the top of the popup.

<group id="Zend.MainNewGroup">
<separator/>
<group id="Zend.NewGroup" text="Zend Generator" popup="true" icon="/icons/zend_framework_action.png" class="fr.wixiweb.idea.zendgenerator.action.ZendGeneratorGroupActionGroup">
<action class="fr.wixiweb.idea.zendgenerator.action.query.CreateQueryAction"
id="fr.wixiweb.idea.zendgenerator.action.query.CreateQueryAction"
text="Create query" />
<add-to-group group-id="NewGroup" anchor="after" relative-to-action="PhpNewGroup"/>
</group>
</group>

About the native icon, thank you for the reply. It's possible to get an icon from a plugin?

The PHP file icon is not present in the AllIcons class.

 

0

> You tell me to put a group inside other group? For me, it's logical to have a parent group at the top of the popup.

You can do this too. But the code you attached still wrong, you add only Zend.NewGroup to NewGroup and do not add Zend.MainNewGroup to anything.

> About the native icon, thank you for the reply. It's possible to get an icon from a plugin?

I think so, AllIcons was just an example. An alternative way is to define your group as a class and set icon there.

0
Avatar
Permanently deleted user

Thank you :)

<group id="Zend.MainNewGroup">
<separator/>
<group id="Zend.NewGroup" text="Zend Generator" popup="true" icon="/icons/zend_framework_action.png" class="fr.wixiweb.idea.zendgenerator.action.ZendGeneratorGroupActionGroup">
<action class="fr.wixiweb.idea.zendgenerator.action.query.CreateQueryAction"
id="fr.wixiweb.idea.zendgenerator.action.query.CreateQueryAction"
text="Create query" />
</group>
<separator/>
<add-to-group group-id="NewGroup" anchor="after" relative-to-action="PhpNewGroup"/>
</group>

> I think so, AllIcons was just an example. An alternative way is to define your group as a class and set icon there.

Do you have an example for that? Because it doesn't work for me: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001808259/comments/360000273759

 

0

It’s the same as allicons, just use another class, e.g. phpicons.

As for dedicated class for group, look for any class extending DefaultActionGroup

0
Avatar
Permanently deleted user

Phpicons class is available only in the PHP plugin, right?

0

I believe it's easier to try than wait for my answer. No, PhpIcons is available for you as you added a depends-tag of php plugin.

0

Please sign in to leave a comment.