2

Looking at this answer, I suppose I am under the assumption that Craft::import() will take an alias, find the path, and import that class into the Craft namespace... which would be the benefit over simply using require_once().

Currently I import with: Craft::import('plugins.myplugin.resources.chargebee.lib.ChargeBee', true);

Which works, however to use ChargeBee.php, I have to reference it from the global namespace. Not sure if this is the expected behaviour, but I would love to work within the Craft namespace if possible. Any help is greatly appreciated!

1

and import that class into the Craft namespace

Nope... it'll import that file, but will use whatever namespace the file is using (including global).

My guess is that the ChargeBee.php file has a ChargeBee class in it that lives in the global namespace, which is why you have to reference it there.

  • 1
    Thanks for clearing that up. So there is currently no good way to bring external resources into the Craft namespace? I suppose that makes sense now that I'm thinking about it... – Paul Kirby Aug 10 '17 at 15:17
  • 1
    And with that, what is the benefit of using Craft::import() over require_once()? – Paul Kirby Aug 10 '17 at 15:19

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.