Hello!
I'm using Phalcon 2 and \Phalcon\Mvc\Micro as a start for my API and need best practices.
For example, i have models Users, Cars, Settings, Contacts. I need to give out a completely different (but stable) structure. Then, i think, i need some facade into Users model that covers all use cases like CRUD, advanced searching (by parameters too) and so on.
I've tried getters but they don't solve problem cuz i need to use normal models in code. Facade just for response to client. And (important!) able to create different independent facades for different clients (e.g., iOS app, website, smth else). Plus, i can in this case better optimize queries to database (if i know that i need user country and city on every request for iOS app only but not for website).
Right now i have method toAPI() in each model of my app when i'm doing it by my hand. This is problem cuz i need to proxy data from request into models from controllers and they are may be different. On the other hand, i'm trying to implement this logic in \App\Controllers\Rest (that is base for others excepth \App\Controllers\Auth and so on) but have too much duplicate code or too much complexity and very low readability, or too much is..else/switch..case.
How do you solve same problems? Maybe, Phalcon-specific library, book, example application source or smth similar?
Thanks in advance!
ps: sorry for my, possibly bad, english ):