<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>

CC BY-SA 3.0
2015-01-12T09:35:33.403Z
2015-01-12T09:35:33.403Z
Sidney Widmer
<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>

CC BY-SA 3.0
2015-01-09T19:59:03.977Z
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.
Justin Kimbrell
<routes><routing>
Route to Controller action (not in a plugin)
# 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.


---

