I want to access a variable created in Plugin itself. In Craft 2, it could be simply done by craft()->pluginName->getVar() but I couldn't find a way in Craft 3. I have tried Craft::$app->pluginName->getVar() but that throws an error.

1 Answer 1


You can access your plugin via


You can then access its components defined by setComponents




If you just want to get properties of your main plugin class it's the same way as above. Not sure what you mean exactly by Plugin Variable

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.