I'm planning on rewritting an application that uses Zend Framework and Twilio (for sending and receiving SMS messages). Looking back, I don't think I placed all of the SMS functionality in the right places. This has made upgrading the website difficult.
Currently, I have an SMS controller that handles requests from Twilio (for incoming messages). I implement a finite state machine (yes, in one big action method) that can handle various commands. Responses are sent directly from this controller, but also from the models that my controllers manage. Because of this, I've ended up with duplicated SMS message templates and confusion as to where exactly a message has originated.
How should I have done this? Should incoming SMS messages be parsed and processed in its own model? Currently, I don't have an SMS model - just an SMS controller. Or, what you suggest?
If it matters, I'm planning on rewriting my application using CakePHP.