The documentation on Craft's website covers registering control panel routes here:
Posting to Controller Actions
Troubleshooting
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:
- Uninstalled the plugin
- Reinstalled the plugin
- 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.
Debugging/Linters
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.