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

MVC UI with web API in one application?

I found a schema here: https://forum.phalcon.io/discussion/2043/mvc-ui-web-api-example but i still get stuck in how to impliment it.

My app have two parts communicate each other. One is MVC UI like a CRUD application show to visitor. One is API provide to others apps. do you guys have any suggest idea or is there any example?

Your API endpoint doesn't have to be separate from your CRUD application. You can just make a route in your application that outputs content as expected by the API.

For example, you can have these routes for your ordinary application (I don't know what your application does, so this is just an example)

/user/profile/1
/cart/checkout/
/login/

Those would all trigger the appropriate controller, do some work, then output an HTML page. You can simply add a route for your API calls:

/api/userProfile/1
/api/cart/checkout/
/api/login

These would all trigger a controller and do some work, but they don't have to output HTML - the can output JSON or XML, or whatever you have specificed for your API.