I have a plugin with the structure something like:

 - PluginVariable.php
 - PluginAnotherVariable.php

Inside PluginVariable.php I have something like:

namespace Craft;

class PluginVariable
   public function foo($parameter)
       $result = craft()->plugin_results->get($parameter);
        return new PluginAnotherVariable($result);

Now when I do {{ craft.plugin.foo('something') }} I just get Fatal error: Class 'Craft\PluginAnotherVariable' not found.

I've checked that the filenames and classnames are identical and the namespacing etc so the class most certainly exists but I can't get this to work, has anyone had a similar issue with this and what could be causing it? Thanks.

1 Answer 1



So I just needed to put an underscore between the plugin handle and variable name so PluginAnotherVariable.php becomes Plugin_AnotherVariable.php and the classname Plugin_AnotherVariable and things are now working :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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