In my custom Twig tag I am trying to reference a class in the Twig_Node compile method, however I receive an error every time stating it can't find it. What would the path be to a custom plugin class for the Twig_Node?

Fatal error: Class 'PluginCustomClass' not found in /Volumes/Grid/Devbox/www/event.craft.dev/craft/app/vendor/twig/twig/lib/Twig/Environment.php(403) : eval()'d code on line 431

public function compile(\Twig_Compiler $compiler)
            ->raw(', ')
            ->raw(') = new \PluginCustomClass(')

1 Answer 1


Assuming PluginCustomClass is a class inside of a Craft plugin, then the issue is probably that you need to reference it in the Craft namespace. Something like this should work:

->raw(') = new \Craft\PluginCustomClass(')

Depending on what type of class that is (Service, Variable, Helper, standalone, etc.), Craft might not have auto-loaded it, so you might need to manually require it as well.

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.