<p>This is the general rule of thumb...</p>

<ul>
<li><strong>Lower (myplugin)</strong> - When creating links for the browser to follow ("href" &amp; "src")</li>
<li><strong>Camel (myPlugin)</strong> - When creating a path for PHP to interpret (like calling an action)</li>
<li><strong>Pascal (MyPlugin)</strong> - Almost never. Only for naming plugin components. (ie: MyPluginService)</li>
</ul>

<p>Here's the logic behind lower vs. camel... If it's an "href" or "src" for your browser to follow, you're basically referring to the <strong>folder name</strong> which contains your plugin. If it's a reference for PHP to interpret, that information is used to trigger a part of your plugin by <strong>class name</strong>.</p>

<p>In the case of a controller action (<code>/actions/myPlugin/foo</code>), that path <strong>starts</strong> as a normal browser path, until <code>actions</code> gets interpreted by your root <code>index.php</code> file. Once the index file parses out the <a href="http://buildwithcraft.com/docs/config-settings#actionTrigger" rel="nofollow">actionTrigger</a>, the rest of the path is handled via PHP.</p>

CC BY-SA 3.0
2014-06-25T16:52:31.123Z
That makes sense.
It still feels a little funny to me that it is case insensitive one way (template/cp routing) and not the other way (controller action).
Tim Kelty
CC BY-SA 3.0
2014-06-25T16:56:05.663Z
I agree, it took me a little while to wrap my head around. Ultimately, the case-insensitivity is just due to server behavior... nothing that Craft can really even do about it. Despite the case-insensitivity, I use lowercase because you're referring to the folder itself (which is lowercase).
Lindsey D
CC BY-SA 3.0
2014-06-25T16:00:04.457Z
2014-06-25T16:21:32.987Z
2014-06-25T16:21:32.987Z
Lindsey D
<p>Recently got tripped up with plugin routing due to casing.</p>

<p>It seems when you're in the control panel, your "plugin handle" is lower-cased in routes, though both seem to work: <code>/cp/settings/plugins/myplugin</code> (/cp/settings/plugins/myPlugin` also works)</p>

<p>However, when using an controller action, it seems like it must be camel cased (<code>/actions/myPlugin/foo</code>).</p>

<p>Seems inconsistent, unless I'm missing some reasoning.</p>

<p>The <a href="http://buildwithcraft.com/docs/plugins/controllers#how-controller-actions-fit-into-routing">docs</a> say <code>[PluginHandle]/[ControllerName]/[ActionName]</code>, but it seems like it's actually <code>[pluginHandle]/[controllerName]/[actionName]</code> as the example shows (<code>cocktailRecipes/ingredients/saveIngredient</code>).</p>

<plugin-development><plugins><controller><uppercase>
Plugin routing casing: camel, lower, Pascal
# Plugin routing casing: camel, lower, Pascal

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

Recently got tripped up with plugin routing due to casing.

It seems when you're in the control panel, your "plugin handle" is lower-cased in routes, though both seem to work: `/cp/settings/plugins/myplugin` (/cp/settings/plugins/myPlugin` also works)

However, when using an controller action, it seems like it must be camel cased (`/actions/myPlugin/foo`).

Seems inconsistent, unless I'm missing some reasoning.

The [docs](http://buildwithcraft.com/docs/plugins/controllers#how-controller-actions-fit-into-routing) say `[PluginHandle]/[ControllerName]/[ActionName]`, but it seems like it's actually `[pluginHandle]/[controllerName]/[actionName]` as the example shows (`cocktailRecipes/ingredients/saveIngredient`).

**Tags:** plugin-development, plugins, controller, uppercase

---

## 1 answers

### Answer by username_1 on 2014-06-25. Score: 3

This is the general rule of thumb...

* **Lower (myplugin)** - When creating links for the browser to follow ("href" & "src")
* **Camel (myPlugin)** - When creating a path for PHP to interpret (like calling an action)
* **Pascal (MyPlugin)** - Almost never. Only for naming plugin components. (ie: MyPluginService)

Here's the logic behind lower vs. camel... If it's an "href" or "src" for your browser to follow, you're basically referring to the **folder name** which contains your plugin. If it's a reference for PHP to interpret, that information is used to trigger a part of your plugin by **class name**.

In the case of a controller action (`/actions/myPlugin/foo`), that path **starts** as a normal browser path, until `actions` gets interpreted by your root `index.php` file. Once the index file parses out the [actionTrigger](http://buildwithcraft.com/docs/config-settings#actionTrigger), the rest of the path is handled via PHP.

> **Comments:**
> **username_0**: That makes sense. It still feels a little funny to me that it is case insensitive one way (template/cp routing) and not the other way (controller action).  
> **username_1**: I agree, it took me a little while to wrap my head around. Ultimately, the case-insensitivity is just due to server behavior... nothing that Craft can really even do about it. Despite the case-insensitivity, I use lowercase because you're referring to the folder itself (which is lowercase).  

---

