We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Avoid exposing model to client/api

I'm developing a REST API with Phalcon and I'm wondering what the best approach would be to avoid exposing raw model data to my endpoints. Should I be using DTO's and/or annotations (if possible with Phalcon) where a DTO might be overkill? Any help/examples would be appreciated.



10.1k

There is a nice example in the repo. https://github.com/phalcon/phalcon-api This should give you some great pointers.