<p>I solved the problem using Pascal Case for naming all my files and classes. I was using camel Case...</p>

<p>So all works fine with those filenames for my "foo" plugin :</p>

<ul>
<li><p>FooPlugin.php</p></li>
<li><p>controllers/FooController.php</p></li>
</ul>

<p>I used Pascal Case for the classes name too, mainly for consistency reason; but i noticed that :</p>

<ul>
<li><p>using camelCase for controller class name if the filename is in PascalCase does not break anything</p></li>
<li><p>using camelCase for plugin classname breaks the controller.</p></li>
</ul>

<p>Anyway, if you don't want issues, juste use Pascal Case (file names and class names) everywhere and you should be Ok.</p>

<p>Please note that with apache, this path is calling my controller correctly (all in lower case)</p>

<pre><code>actions/foo/hello
</code></pre>

CC BY-SA 3.0
2014-06-30T07:30:19.400Z
2014-06-30T07:30:19.400Z
yann_yinn
<p><strong>Typo:</strong></p>

<p>Depending on your plugin-handle you may have a typo in your action routes. It's important to note that this routes are 'Camel' case-sensitive. <a href="https://craftcms.stackexchange.com/a/470/177">Read this answer by Lindsey for more info</a>.</p>

<p><strong>Access:</strong></p>

<p>You need to add your action to <code>$allowAnonymous</code>, otherwise only users who are logged in can access the controller:</p>

<pre class="lang-php prettyprint-override"><code>protected $allowAnonymous = array('actionHello');
</code></pre>

CC BY-SA 3.0
2014-06-29T13:14:48.577Z
Thanks for your anwser. My plugin directory is "foo", my controller is "controllers/fooController.php" and inside, my action is "actionHello", so from what i read, my path should be "actions/foo/Hello" . Tried others combinations and playing with case with no success. Surely i missed something stupid in my way ... Also added $allowAnonymous array just in case, but i'm logged in for my tests.
yann_yinn
CC BY-SA 3.0
2014-06-29T13:48:08.067Z
Ok, solved, I added my answer at the top of my question.
yann_yinn
CC BY-SA 3.0
2014-06-29T11:06:51.900Z
2014-06-29T11:06:51.900Z
2017-04-13T12:51:00.303Z
Victor
<p>I'm trying to create a very simple controller from a "foo plugin", but it seems there is something i did not understand because i can't make it work. (404 error)
I looked at contactForm plugin as an example; except i'm trying to respond to a "GET" http request.</p>

<p>My plugin is enable and OK. 
My plugin is "foo". Here is my controller, in plugins/foo/controllers :</p>

<pre><code>&lt;?php
namespace Craft;

/**
 * Contact Form controller
 */
class fooController extends BaseController {

  function actionHello() {
     $this-&gt;renderTemplate('foo/test');
  }

}
?&gt;
</code></pre>

<p>This is not supposed to be called with this uri ?</p>

<pre><code>http://craft.local/index.php?p=actions/foo/Hello
</code></pre>

<p>Must i register a route to make this work ?</p>

<p>Also tried renaming my controller and class to "foo_testController", and then calling :</p>

<pre><code>http://craft.local/index.php?p=actions/foo/test/Hello
</code></pre>

<p>without success.</p>

<p>What am i missing ?</p>

CC BY-SA 3.0
2014-06-29T20:06:41.007Z
No harm in editing your own question if you don't have the rep to answer it properly... However, once you do have enough rep points, I'd suggest moving that to a real answer to improve clarity for future readers.
Lindsey D
CC BY-SA 3.0
2014-06-30T07:33:03.537Z
okay thanks for your help; i just created a real answer
yann_yinn
<controller>
How to create a basic plugin front-end controller?
# How to create a basic plugin front-end controller?

(Asked by: username_0 on 2014-06-29)

I'm trying to create a very simple controller from a "foo plugin", but it seems there is something i did not understand because i can't make it work. (404 error)
I looked at contactForm plugin as an example; except i'm trying to respond to a "GET" http request.
My plugin is enable and OK. 
My plugin is "foo". Here is my controller, in plugins/foo/controllers :
renderTemplate('foo/test');
  }

}
?>

This is not supposed to be called with this uri ?
http://craft.local/index.php?p=actions/foo/Hello

Must i register a route to make this work ?
Also tried renaming my controller and class to "foo_testController", and then calling :
http://craft.local/index.php?p=actions/foo/test/Hello

without success.
What am i missing ?

**Tags:** controller

> **Comments:**
> **username_1**: No harm in editing your own question if you don't have the rep to answer it properly... However, once you do have enough rep points, I'd suggest moving that to a real answer to improve clarity for future readers.  
> **username_0**: okay thanks for your help; i just created a real answer  

---

## 2 answers

### Answer by username_0 on 2014-06-30. Score: 3 | Accepted answer

I solved the problem using Pascal Case for naming all my files and classes. I was using camel Case...
So all works fine with those filenames for my "foo" plugin :

FooPlugin.php
controllers/FooController.php

I used Pascal Case for the classes name too, mainly for consistency reason; but i noticed that :

using camelCase for controller class name if the filename is in PascalCase does not break anything
using camelCase for plugin classname breaks the controller.

Anyway, if you don't want issues, juste use Pascal Case (file names and class names) everywhere and you should be Ok.
Please note that with apache, this path is calling my controller correctly (all in lower case)
actions/foo/hello


---

### Answer by username_2 on 2014-06-29. Score: 1

Typo:
Depending on your plugin-handle you may have a typo in your action routes. It's important to note that this routes are 'Camel' case-sensitive. Read this answer by Lindsey for more info.
Access:
You need to add your action to $allowAnonymous, otherwise only users who are logged in can access the controller:
protected $allowAnonymous = array('actionHello');

> **Comments:**
> **username_0**: Thanks for your anwser. My plugin directory is "foo", my controller is "controllers/fooController.php" and inside, my action is "actionHello", so from what i read, my path should be "actions/foo/Hello" . Tried others combinations and playing with case with no success. Surely i missed something stupid in my way ... Also added $allowAnonymous array just in case, but i'm logged in for my tests.  
> **username_0**: Ok, solved, I added my answer at the top of my question.  

---

