Answers.Body: <p>The problem ended up being something underlying in craft or yii2 that will not route the word "echo".</p>
  
  <p>I changed out "echo" to "test" and it works fine. Even with both routes in, one does not and one does:</p>
  
  <pre><code>    // Register our site routes
      Event::on(
          UrlManager::class,
          UrlManager::EVENT_REGISTER_SITE_URL_RULES,
          function (RegisterUrlRulesEvent $event) {
              $event-&gt;rules['echo'] = 'site-dom-injector/default/index';
              $event-&gt;rules['test'] = 'site-dom-injector/default/index';
          }
      );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-17T18:57:33.210Z
Answers.Text: That's... weird.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-19T19:17:05.877Z
Answers.Text: huh. I guess because it's a reserved word in PHP? But even that doesn't make sense, I can't see how it'd care from a routing perspective. Is it possible that there's a server-side setting that's causing that request to just never hit Craft?
Answers.UserDisplayName: andrew.welch
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-17T16:22:53.473Z
Answers.LastActivityDate: 2017-11-17T16:22:53.473Z
Answers.UserDisplayName: Rick Kukiela
Body: <p>Before I get tagged as a duplicate I have already tried everything in the 'duplicate' issues on here to no avail so I'm posting my exact config to see what I'm doing wrong.</p>
  
  <p>Here is my plugin code and my controller code</p>
  
  <pre><code>// My plugin and init funciton
  use belniakmedia\sitedominjector\controllers\DefaultController;
  class SiteDomInjector extends Plugin
  {
      /**
       * @var SiteDomInjector
       */
      public static $plugin;
  
      /** @var array */
      public $controllerMap = [
          'default' =&gt; DefaultController::class,
      ];
      public function init()
      {
          parent::init();
          self::$plugin = $this;
  
          // Register our site routes
          Event::on(
              UrlManager::class,
              UrlManager::EVENT_REGISTER_SITE_URL_RULES,
              function (RegisterUrlRulesEvent $event) {
                  $event-&gt;rules['echo'] = 'site-dom-injector/default/index';
              }
          );
      }
  }
  
  // My Controller
  class DefaultController extends Controller
  {
      protected $allowAnonymous = true;
  
      public function actionIndex()
      {
          $result = 'Welcome to the DefaultController actionIndex() method';
          return $result;
      }
  }
  </code></pre>
  
  <p>I really don't know if that controller map is necessary or not but one of the posts on here said they got it to work setting that up, so thats what I did.</p>
  
  <p>Here is a photo of my plugin's file structure for continuity:</p>
  
  <p><a href="https://i.sstatic.net/1M1bV.png" rel="noreferrer"><img src="https://i.sstatic.net/1M1bV.png" alt="enter image description here"></a>
  I really have no idea why this isnt working but no matter what I do, when I try to browse to <a href="http://site.local/echo" rel="noreferrer">http://site.local/echo</a> I get a 404 not found and the trace seems like its not even attempting to load the controller and is just looking for a matching template file... :(</p>
  
  <p>Any ideas?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-16T23:37:31.880Z
Comments.Text: Before anyone asks, yes the plugin is installed and enabled!
Comments.UserDisplayName: Rick Kukiela
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-17T06:49:44.780Z
Comments.Text: I'm not sure if that's really the problem but have you tried to route to `site-dom-injector/default` when I create your plugin with Pluginfactory.io the default output is `$event->rules['siteActionTrigger1'] = 'site-dom-injector/default-controller';` so - I could be totally wrong - but maybe the controller will only route to Index if you don't declare anything
Comments.UserDisplayName: Robin Schambach
Tags: <plugin-development><routing><craft3>
Title: How to route to a controller action in Craft3?
ThreadText: # How to route to a controller action in Craft3?
  
  (Asked by: username_0 on 2017-11-16)
  
  Before I get tagged as a duplicate I have already tried everything in the 'duplicate' issues on here to no avail so I'm posting my exact config to see what I'm doing wrong.
  
  Here is my plugin code and my controller code
  
  ```
  // My plugin and init funciton
  use belniakmedia\sitedominjector\controllers\DefaultController;
  class SiteDomInjector extends Plugin
  {
      /**
       * @var SiteDomInjector
       */
      public static $plugin;
  
      /** @var array */
      public $controllerMap = [
          'default' => DefaultController::class,
      ];
      public function init()
      {
          parent::init();
          self::$plugin = $this;
  
          // Register our site routes
          Event::on(
              UrlManager::class,
              UrlManager::EVENT_REGISTER_SITE_URL_RULES,
              function (RegisterUrlRulesEvent $event) {
                  $event->rules['echo'] = 'site-dom-injector/default/index';
              }
          );
      }
  }
  
  // My Controller
  class DefaultController extends Controller
  {
      protected $allowAnonymous = true;
  
      public function actionIndex()
      {
          $result = 'Welcome to the DefaultController actionIndex() method';
          return $result;
      }
  }
  
  ```
  
  I really don't know if that controller map is necessary or not but one of the posts on here said they got it to work setting that up, so thats what I did.
  
  Here is a photo of my plugin's file structure for continuity:
  
  [![enter image description here](https://i.sstatic.net/1M1bV.png)](https://i.sstatic.net/1M1bV.png)
  I really have no idea why this isnt working but no matter what I do, when I try to browse to <http://site.local/echo> I get a 404 not found and the trace seems like its not even attempting to load the controller and is just looking for a matching template file... :(
  
  Any ideas?
  
  **Tags:** plugin-development, routing, craft3
  
  > **Comments:**
  > **username_0**: Before anyone asks, yes the plugin is installed and enabled!  
  > **username_1**: I'm not sure if that's really the problem but have you tried to route to `site-dom-injector/default` when I create your plugin with Pluginfactory.io the default output is `$event->rules['siteActionTrigger1'] = 'site-dom-injector/default-controller';` so - I could be totally wrong - but maybe the controller will only route to Index if you don't declare anything  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-11-17. Score: 3
  
  The problem ended up being something underlying in craft or yii2 that will not route the word "echo".
  
  I changed out "echo" to "test" and it works fine. Even with both routes in, one does not and one does:
  
  ```
      // Register our site routes
      Event::on(
          UrlManager::class,
          UrlManager::EVENT_REGISTER_SITE_URL_RULES,
          function (RegisterUrlRulesEvent $event) {
              $event->rules['echo'] = 'site-dom-injector/default/index';
              $event->rules['test'] = 'site-dom-injector/default/index';
          }
      );
  
  ```
  
  > **Comments:**
  > **username_2**: That's... weird.  
  > **username_3**: huh. I guess because it's a reserved word in PHP? But even that doesn't make sense, I can't see how it'd care from a routing perspective. Is it possible that there's a server-side setting that's causing that request to just never hit Craft?  
  
  ---
  
  