How to access Craft classes within plugin?
craft() is just a wrapper for the singleton instance of the WebApp class and you can call its methods directly like you're doing with getSiteUrl().

You'll notice that getSiteUrl() actually isn't in that list of WebApp methods, though.  That's because it (along with other methods) live in AppBehavior, which is a Yii behavior and is very similar to a trait that gets it's methods "mixed-in" to the class that wants them (in this case, WebApp).

Stand-alone classes that are't attached to WebApp (craft()), like DateTime, you can instantiate like:

$dateTime = new DateTime();
$dateTime-&gt;format(...);


Or if they are static classes (like the Helpers), you can use directly like:

$lowerCaseString = StringHelper::toLowerCase('ABC');