<p>Please remove the first <code>\</code> and include a vendor directory</p>

<pre><code>11 namespace [package]\[websitename];
12 
13 use [package]\[websitename]\variables\[websitename]Variable;
</code></pre>

<p>The namespace must always consist the package and the plugin name <a href="https://docs.craftcms.com/v3/plugin-intro.html" rel="nofollow noreferrer">docs</a></p>

<p><a href="https://docs.craftcms.com/v3/plugin-intro.html#primary-plugin-class" rel="nofollow noreferrer">Here</a> is an example</p>

<pre><code>namespace ns\prefix; // &lt;-- see: ns\prefix, not only prefix

class Plugin extends \craft\base\Plugin
</code></pre>

CC BY-SA 4.0
2018-06-06T11:53:39.510Z
Yes, this is the answer, thank you @Robin.
The plugin vendor is not a required field in the plugin creator, so I assumed it was optional and hadn't filled it in. Adding a plugin vendor makes it all work.
Jai Redden
CC BY-SA 4.0
2018-06-06T11:41:36.080Z
2018-06-06T11:41:36.080Z
Robin Schambach
<p>I'm trying to create a new plugin for my website in Craft CMS 3, just to do some really basic stuff, like parsing an XML file from an external site.</p>

<p>I created it using the plugin creator at <a href="https://pluginfactory.io/" rel="nofollow noreferrer">https://pluginfactory.io/</a> as per the craft docs. I have only included the controller and variable components.</p>

<p>I've added it in to my composer.json file, run the composer require command and it has successfully been added to the plugins list with my craft install. However, when I go try and install it from the plugins page, I get this error:
"The use statement with non-compound name 'Craft' has no effect in /var/www/html/[websitename]/plugins/[websitename]/src/[websitename].php at line 15"</p>

<p>This is what the code that has been generated looks like (website name redacted):</p>

<pre><code>11 namespace \[websitename];
12  
13 use \[websitename]\variables\[websitename]Variable;
14  
15 use Craft;
16 use craft\base\Plugin;
17 use craft\services\Plugins;
18 use craft\events\PluginEvent;
19 use craft\web\UrlManager;
20 use craft\web\twig\variables\CraftVariable;
21 use craft\events\RegisterUrlRulesEvent;
22  
23 use yii\base\Event;
</code></pre>

<p>Does anyone have any idea what is happening here? I've tried reading the plugin docs but I can't see what is going wrong. I assume the plugin creator is generating files correctly, I've used it several times for Craft 2, but this is my first attempt at a Craft 3 plugin.</p>

<p>Thanks, Jai.</p>

<plugin-development>
Exception on trying to install Craft CMS 3 plugin
# Exception on trying to install Craft CMS 3 plugin

(Asked by: username_0 on 2018-06-06)

I'm trying to create a new plugin for my website in Craft CMS 3, just to do some really basic stuff, like parsing an XML file from an external site.
I created it using the plugin creator at https://pluginfactory.io/ as per the craft docs. I have only included the controller and variable components.
I've added it in to my composer.json file, run the composer require command and it has successfully been added to the plugins list with my craft install. However, when I go try and install it from the plugins page, I get this error:
"The use statement with non-compound name 'Craft' has no effect in /var/www/html/[websitename]/plugins/[websitename]/src/[websitename].php at line 15"
This is what the code that has been generated looks like (website name redacted):
11 namespace \[websitename];
12  
13 use \[websitename]\variables\[websitename]Variable;
14  
15 use Craft;
16 use craft\base\Plugin;
17 use craft\services\Plugins;
18 use craft\events\PluginEvent;
19 use craft\web\UrlManager;
20 use craft\web\twig\variables\CraftVariable;
21 use craft\events\RegisterUrlRulesEvent;
22  
23 use yii\base\Event;

Does anyone have any idea what is happening here? I've tried reading the plugin docs but I can't see what is going wrong. I assume the plugin creator is generating files correctly, I've used it several times for Craft 2, but this is my first attempt at a Craft 3 plugin.
Thanks, Jai.

**Tags:** plugin-development


---

## 1 answers

### Answer by username_1 on 2018-06-06. Score: 3 | Accepted answer

Please remove the first \ and include a vendor directory
11 namespace [package]\[websitename];
12 
13 use [package]\[websitename]\variables\[websitename]Variable;

The namespace must always consist the package and the plugin name docs
Here is an example
namespace ns\prefix; // <-- see: ns\prefix, not only prefix

class Plugin extends \craft\base\Plugin

> **Comments:**
> **username_0**: Yes, this is the answer, thank you @Robin. The plugin vendor is not a required field in the plugin creator, so I assumed it was optional and hadn't filled it in. Adding a plugin vendor makes it all work.  

---

