Sorry, rusty at PHP and learning Craft.

My code looks like this:

$url = craft::$app->GeneralConfig->siteUrl();

What am I doing wrong? I want to build a URL for some links in a plugin.


Please use a proper IDE or take a look into the source code to get to know the functions of the class. As you can see in the class reference the function is called


However - in order to create urls you should use the UrlHelper

  • 1
    you have referenced a "good IDE" in another question of mine as well. See [link]craftcms.stackexchange.com/a/25288/8071. You seem to have strong opinions about IDE's. What specifically in your estimation is a good or proper IDE? Are there ways to set up IDE's to get Craft classes autocompleted? Are there plugins that help? Can you recommend a specific IDE or environment? I am open to what a "proper IDE" is, please tell me. I am currently using Netbeans. Apr 9 '18 at 1:48
  • I would not even start to create a plugin without autocomplete, because it saves you so much time. NetBeans should be capable, but I personally don't like it at all. Here is a good article about the topic nystudio107.com/blog/… Phpstorm completes your code automatically, warns you about deprecated functions, enables twig autosuggestion, explains all functions, properties and magic methods a class has and so on. So when you type Craft:: you'll see every possibility you have. No plugin needed, no real setup needed Apr 9 '18 at 5:29
  • 1
    Wow...oh wow! Using PHPStorm is massively helpful. I just learned how to set up a vagrant box with PHPStorm with xdebug. Wow...mind blown. Was used to this kind of capability using Visual Studio for VB.net. I always hated how primitive using echos, print_r and their ilk in doing web development. Mind blown. Thanks for pushing me @Robin. I appreciate your help. Apr 30 '18 at 0:33

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.