Can you post what your end point looks like?
-
☆ A M B ☆
- 3,141 Posts
Can you check your PHP and MODX error logs as well? That hopefully gives a better error message. The nginx one basically just says PHP didn't return what it expected.
Could be an issue where the name of your controller does not match the required/configured naming pattern.
MODX is very picky about the class name of a controller, and not very graceful when you get it wrong.
IIRC, the format is: modNamespaceAction...Controller
(The part where the dots are is optional -- it's often "Manager" for CMPs.)
You should also return the controller class name at the end of the class file (outside of the class):
return 'LoginConfirmRegisterController';
Sorry if I confused you. The 'mod' is not necessary. In my example, you'd replace 'modNameSpace' with the actual namespace name. You'd also put the word "Controller" at the end, not the beginning.
If you don't have a Menu item in the Manager to call your controller, you may not need the "action" part, but "Controller" may still need to be at the end.
I'd also recommend putting your controller in the core/components/mynamespace/controllers/ directory.
When you load a controller with the path: core/components/mynamespace/controllers/mycontroller.class.php, MODX expects to find a class inside that's named MynamespaceMycontrollerController. If it doesn't, it thinks it has the wrong file and bails out. The first part is the actual name of the namespace. The second is the name of the action, but should match the first part of the filename except for case (filename in lowercase). The third part is just the word "Controller."
The Quotations class isn't really relevant because there's no controller -- it's just a standard HTML form with a snippet.
All that said, your controller file may contain a syntax error that's causing the server error. In that case correcting the controller name won't fix things. A good code editor like PhpStorm is worth its weight in gold for flagging syntax errors that might otherwise take hours to track down, especially since PHP 7 likes to throw a server error instead of a specific PHP error when it finds bad syntax.
[ed. note: BobRay last edited this post 5 years, 11 months ago.]