I'm having trouble registering a CP route. What I have is a "working" SiteAdministrator_UserController.php (other form save actions already work through this controller, so its functional). Inside the controller I have a function :

public function actionCurrent()
    die ('Works!');

In my Plugin I have the following:

public function registerCpRoutes()
    return array(
        'siteadministator/currentusers' => array('action' => 'siteAdministrator/user/current')

trying the uri http://cms.craft.dev/admin/siteadministrator/currentusers

Craft says its a 404.

What am I doing wrong and/or is there a way to debug this?

Thanks in advance

  • Can you post your entire controller code? Minus any details you do not want to share of course. Jul 27, 2014 at 21:01

3 Answers 3


Based on your code excerpts, things look good. I've encountered issues with spelling and caps when referencing controllers and templates within my controllers...so pay close attention to them.

I would suggest referencing the 'Cocktail Recipes' sample plugin: https://github.com/seandelaney/cocktailrecipes (Craft 2.x) as it contains an example of what you're trying to do.

EDIT: Updated link to Craft 2.x version as per comment below.


Dumb ass typo : "siteadministator" instead of siteadministRator sigh ... Sorry for taking up bytes.

Working method now is:

public function hookRegisterCpRoutes()
    return array(
        'siteadministrator/currentusers' => array('action' => 'siteAdministrator/user/current'),

The documentation on Craft's website covers registering control panel routes here:

Posting to Controller Actions


According to the documentation your route is setup correctly. I have had an experience where a route would not register. I took the following steps to troubleshoot:

  1. Uninstalled the plugin
  2. Reinstalled the plugin
  3. Checked spelling on the controller and the main plugins class 'registerCpRoutes' method.

However, if you are at a point where uninstalling is out of the question, I would again check for spelling and make sure there are no typos or missing brackets in the controller and main plugin class. In my case, I found a small typo and that corrected my issue.


Depending on what text editor you are using, you might also want to look at using a Linter. A linter for PHP essentially runs the command line php -l which will check the syntax on your PHP file.

I use Atom on a daily basis and use the Atom Linter package. However, I know Sublime has a Linter package as well but I am not familiar with that one.

Helper Plugins

You may also want to look into installing this plugin from Matt Stauffer: Plugin Dev Helpers. This will allow you to use the 'die and dump' helper that exists in the Laravel framework. Essentially allowing you to use dd($anyVariableName), which will dump and die but allows you to pass variables to the output.

  • Computer says no...:(
    – pythic
    Jul 27, 2014 at 20:48
  • Yeah, you are right. Just looked at some of my code and realized I was wrong. Looking into it now. Jul 27, 2014 at 20:50
  • I updated the answer, let me know if I can help. Jul 27, 2014 at 21:10
  • I'll try the above tomorrow, its getting kind of late over here. I have a client waiting in the morning :) Thank you so far
    – pythic
    Jul 27, 2014 at 21:15
  • 1
    Thanks for all the tips above. What I did notice is that in the cocktailrecipe example the registerCpRoutes method is not used, he uses hookRegisterCpRoutes. Not sure that the difference is but they both get called by the framework. Anyway that didn't solve my problem... What did solve it is that after 14 hrs of coding I made a typo, its hiding in plain sight... "siteadministator" instead of siteadministRator sigh ... Sorry for taking up bytes.
    – pythic
    Jul 28, 2014 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.