Answers.Body: <p>As it turns out it's not really possible to break out of the intended craft workflow. If you don't want to put additional business logic in plugins, you're only option is changing the index file. Which I did like this: </p>
  
  <pre><code>try
  {
      $app-&gt;run();
  }
  catch(CHttpException $exception)
  {
      // Implement custom route logic here
      // If nothing matches your own routes, just rethrow the $exception
      // like so:
      //throw $exception;
  }
  </code></pre>
  
  <p>I'm more playing around here the learn how craft works, in the end the best solution is probably to just go with a plugin. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-12T09:35:33.403Z
Answers.LastActivityDate: 2015-01-12T09:35:33.403Z
Answers.UserDisplayName: Sidney Widmer
Body: <p>Let's say i have a <code>FooController</code> extending <code>Craft\BaseController</code> located somewhere else (not in a plugin). The <code>FooController</code> is autoloaded via composer and the autoload.php is included in public/index.php</p>
  
  <p>Would there be a way to route to this <code>FooController</code>? Is it not possible with Craft (or Yii) to just say something laravel like: <code>Route::get('foo/bar', 'FooController@bar')</code>? </p>
  
  <p><strong>Edit</strong> (follow up question):
  If I have something like this in my <code>registerSiteRoutes</code> function:</p>
  
  <pre><code> return [
       'foo/bar' =&gt; ['action' =&gt; 'plugin/foo/bar', 'additional' =&gt; 'acme'],
   ];
  </code></pre>
  
  <p>Would I be able to access the 'additional' information in the controller?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-09T19:59:03.977Z
Comments.Text: I am leaving this as a comment, because I am not confident enough it's correct enough to post this an answer. But based on my experience, you need to have it located in the `controllers` directory in your plugin. One option, again perhaps not the only or best option, would be to use a controller in the `controller` directory that is merely a wrapper to call the function elsewhere. Just a thought.
Comments.UserDisplayName: Justin Kimbrell
Tags: <routes><routing>
Title: Route to Controller action (not in a plugin)
ThreadText: # Route to Controller action (not in a plugin)
  
  (Asked by: username_0 on 2015-01-08)
  
  Let's say i have a `FooController` extending `Craft\BaseController` located somewhere else (not in a plugin). The `FooController` is autoloaded via composer and the autoload.php is included in public/index.php
  
  Would there be a way to route to this `FooController`? Is it not possible with Craft (or Yii) to just say something laravel like: `Route::get('foo/bar', 'FooController@bar')`?
  
  **Edit** (follow up question):
  If I have something like this in my `registerSiteRoutes` function:
  
  ```
   return [
       'foo/bar' => ['action' => 'plugin/foo/bar', 'additional' => 'acme'],
   ];
  
  ```
  
  Would I be able to access the 'additional' information in the controller?
  
  **Tags:** routes, routing
  
  > **Comments:**
  > **username_1**: I am leaving this as a comment, because I am not confident enough it's correct enough to post this an answer. But based on my experience, you need to have it located in the `controllers` directory in your plugin. One option, again perhaps not the only or best option, would be to use a controller in the `controller` directory that is merely a wrapper to call the function elsewhere. Just a thought.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-01-12. Score: 1
  
  As it turns out it's not really possible to break out of the intended craft workflow. If you don't want to put additional business logic in plugins, you're only option is changing the index file. Which I did like this:
  
  ```
  try
  {
      $app->run();
  }
  catch(CHttpException $exception)
  {
      // Implement custom route logic here
      // If nothing matches your own routes, just rethrow the $exception
      // like so:
      //throw $exception;
  }
  
  ```
  
  I'm more playing around here the learn how craft works, in the end the best solution is probably to just go with a plugin.
  
  
  ---
  
  