<p>For craft cms 3</p>

<pre><code>{% set plugin = craft.app.plugins.getPlugin('plugin-handle', false) %}


{% if plugin is not null and plugin.isInstalled %}
....
    call plugin related stuff here
.....
{% endif %}
</code></pre>

<blockquote>
  <p>To check plugin handle.</p>
</blockquote>

<ol>
<li>Open composer.json of your plugin.</li>
<li>Search for <code>handle</code> param in that file, that's the plugin handle.</li>
</ol>

CC BY-SA 4.0
2019-05-15T07:41:39.897Z
2019-05-15T07:41:39.897Z
inrsaurabh
<p>A simple way to check that a plugin is both installed and enabled is to use Twig's <code>is defined</code> test (since <code>craft.pluginHandle</code> is defined only if the plugin is both installed and enabled):</p>

<pre><code>{% if craft.pluginHandle is defined %}
  ...
{% endif %}
</code></pre>

<p>(Credit due to <a href="https://craftcms.stackexchange.com/a/7028/328">this answer</a>)</p>

CC BY-SA 3.0
2016-04-18T11:17:00.497Z
2016-04-18T11:17:00.497Z
2017-04-13T12:51:00.253Z
Nick F
<p>It should show up in the control panel in the plugins section. It will show the name of the plugin and if it is enabled. I've had issues when i didn't setup the folder correctly. Double check the plugin documentation, it should tell you what folder to place within the craft plugins directory. </p>

CC BY-SA 3.0
2015-07-20T23:16:18.137Z
2015-07-20T23:16:18.137Z
Justin K
<p>On top of checking within the admin area, there are some other ways you can do this, both in templates and in your plugins.</p>

<p><strong>In a template</strong></p>

<pre><code>{# Second argument is if you want enabled only #}
{% set plugin = craft.plugins.getPlugin('pluginHandle', false) %}

{# Now you have access to these methods... #}
{{ plugin.isEnabled() }}
{{ plugin.isInstalled() }}
</code></pre>

<p>For a full list of methods, see <a href="https://buildwithcraft.com/classreference/variables/PluginVariable" rel="noreferrer"><code>PluginVariable</code></a> in craft docs.</p>

<p>For more info on how to get plugins within your templates, see the <a href="https://buildwithcraft.com/classreference/variables/PluginsVariable" rel="noreferrer"><code>PluginsVariable</code></a>, note this is different from <code>PluginVariable</code>.</p>

<p><strong>In your plugin</strong></p>

<p>To check a plugin from within your own plugin:</p>

<pre><code>// Again, second arg is if you just want enabled plugins
$plugin = craft()-&gt;plugins-&gt;getPlugin('pluginHandle', false);

// Then you can do things like:
$plugin-&gt;isInstalled
$plugin-&gt;isEnabled;
</code></pre>

<p>See the <a href="https://buildwithcraft.com/classreference/services/PluginsService" rel="noreferrer"><code>PluginService</code></a> and also the <a href="https://buildwithcraft.com/classreference/etc/plugins/BasePlugin" rel="noreferrer"><code>BasePlugin</code></a> for more info.</p>

<p>Hope that helps :)</p>

CC BY-SA 3.0
2015-07-22T11:34:12.860Z
Thanks Alec, this is exactly what I was after. To elaborate on my purpose for this: My plugin relies on the basis that certain fieldtypes are created first. I could check for the fieldtype itself, but I found myself doing a lot of long winded (is defined and is not null and *fieldtype*|length) checks that was making the code look untidy. A simple check to see if the plugin is active in the first place allow me to create more informative conditions. Now I can tell the user "This page isn't working because..." as apposed to an immediate error page as soon as the plugin is installed.
Mark Notton
CC BY-SA 3.0
2015-07-22T13:52:24.270Z
No worries! and if your plugin is relying on certain fieldtypes being created, are these something you could create within the `onAfterInstall` method on the plugin? that way you can always be sure the fieldtypes will be there and will also minimise user error, fieldtype handle mismatches and so forth.
Alec Ritson
CC BY-SA 3.0
2015-10-12T15:11:16.863Z
Am I right in thinking that `pluginHandle` corresponds to the directory name of the plugin? Couldn't find any documentation on this, but after a bit of trial and error that's what worked for me.
Nick F
CC BY-SA 4.0
2019-05-15T07:42:47.810Z
For craft cms 3 see me answer.
inrsaurabh
CC BY-SA 3.0
2015-07-21T07:52:05.853Z
2017-01-08T05:57:26.440Z
2017-01-08T05:57:26.440Z
Alec Ritson
<p>As the title suggests, I was wondering how to check if a certain plugin exists (and has been installed).</p>
<p>And secondly, check that the plugin is actually enabled.</p>

CC BY-SA 3.0
2015-07-20T23:14:56.173Z
Can you elaborate? Do you need to check from somewhere else other than the "/admin/settings/plugins" screen?
Rick
<plugins>
How can I check if a plugin is installed and enabled?
# How can I check if a plugin is installed and enabled?

(Asked by: username_0 on 2015-07-20)

As the title suggests, I was wondering how to check if a certain plugin exists (and has been installed).

And secondly, check that the plugin is actually enabled.

**Tags:** plugins
> **Comments:**
> **username_1**: Can you elaborate? Do you need to check from somewhere else other than the "/admin/settings/plugins" screen?  

---

## 4 answers

### Answer by username_5 on 2015-07-21. Score: 17 | Accepted answer

On top of checking within the admin area, there are some other ways you can do this, both in templates and in your plugins.
In a template
{# Second argument is if you want enabled only #}
{% set plugin = craft.plugins.getPlugin('pluginHandle', false) %}

{# Now you have access to these methods... #}
{{ plugin.isEnabled() }}
{{ plugin.isInstalled() }}

For a full list of methods, see PluginVariable in craft docs.
For more info on how to get plugins within your templates, see the PluginsVariable, note this is different from PluginVariable.
In your plugin
To check a plugin from within your own plugin:
// Again, second arg is if you just want enabled plugins
$plugin = craft()->plugins->getPlugin('pluginHandle', false);

// Then you can do things like:
$plugin->isInstalled
$plugin->isEnabled;

See the PluginService and also the BasePlugin for more info.
Hope that helps :)

> **Comments:**
> **username_0**: Thanks Alec, this is exactly what I was after. To elaborate on my purpose for this: My plugin relies on the basis that certain fieldtypes are created first. I could check for the fieldtype itself, but I found myself doing a lot of long winded (is defined and is not null and *fieldtype*|length) checks that was making the code look untidy. A simple check to see if the plugin is active in the first place allow me to create more informative conditions. Now I can tell the user "This page isn't working because..." as apposed to an immediate error page as soon as the plugin is installed.  
> **username_5**: No worries! and if your plugin is relying on certain fieldtypes being created, are these something you could create within the `onAfterInstall` method on the plugin? that way you can always be sure the fieldtypes will be there and will also minimise user error, fieldtype handle mismatches and so forth.  
> **username_3**: Am I right in thinking that `pluginHandle` corresponds to the directory name of the plugin? Couldn't find any documentation on this, but after a bit of trial and error that's what worked for me.  
> **username_2**: For craft cms 3 see me answer.  

---

### Answer by username_2 on 2019-05-15. Score: 7

For craft cms 3
{% set plugin = craft.app.plugins.getPlugin('plugin-handle', false) %}


{% if plugin is not null and plugin.isInstalled %}
....
    call plugin related stuff here
.....
{% endif %}


To check plugin handle.


Open composer.json of your plugin.
Search for handle param in that file, that's the plugin handle.


---

### Answer by username_3 on 2016-04-18. Score: 4

A simple way to check that a plugin is both installed and enabled is to use Twig's is defined test (since craft.pluginHandle is defined only if the plugin is both installed and enabled):
{% if craft.pluginHandle is defined %}
  ...
{% endif %}

(Credit due to this answer)


---

### Answer by username_4 on 2015-07-20. Score: 3

It should show up in the control panel in the plugins section. It will show the name of the plugin and if it is enabled. I've had issues when i didn't setup the folder correctly. Double check the plugin documentation, it should tell you what folder to place within the craft plugins directory.


---

