I haven't seen any answers specifically addressing this. While I did find a workaround, there's a bit of a gap in knowledge or guidance on this one, it seems.

I'm developing a plugin as prescribed in the Craft Docs, where my plugins folder is outside of my Craft folder:

"minimum-stability": "dev", "prefer-stable": true, "repositories": [ { "type": "path", "url": "../dev/craft-campaignmonitor-transactional" } ]

This is working great! After seeing a bunch of code work I ran composer require in my plugin to add a required package there, and it installed in my vendor directory for my plugin.

No matter what I tried, though, I kept getting "Class not found" errors for that package's class when I tried to use it in my plugin code.

Only when I ran composer require on the package in my Craft directory did it work in my plugin.

I can understand why this is happening...but should I be able to work on a plugin outside the Craft directory and keep vendor packages out of the Craft directory until I'm ready to install it? Or is this a necessary workaround while in development?

2 Answers 2


You should not do that at all. The entire process to install plugins via composer instead of the old way is to avoid this conflict. Imagine two of your plugins require the same class/library so you'll end up with a class already declared exception. Instead you can insert your requirements into the composer json of your plugin, run the composer update command for your Craft composer json and you are fine.

All dependencies will be loaded into the correct vendor folder.

  • Thanks for the reply! You've said what I "should not" do, but what you say I can do is what I did...and it didn't work. Bear in mind I did not yet install the plugin, it's being referenced by symlink per the docs, while in development. I'm trying to understand how to work on a plugin in that mode, without installing it, and without installing the dependency directly. Apr 22, 2018 at 22:19

I figured it out. composer update in my Craft directory was not seeing the new required package in my plugin's composer.json file. I'm assuming this was based on specified versions or not bumping the version so that it would update the plugin package.

  • It depends on how you included your plugin into Crafts composer json. When you insert a specific version there it won't recognize newer versions beyond Apr 23, 2018 at 5:18
  • Yeah, that seemed to be the issue. Thanks again for replying! Apr 23, 2018 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.