Thanks jlrdw,
I have read that topic but didn't solve my problem.
Already exists a mobile versione of the site with media queries but the client required me to develop native app, so I need to create a api to connect the mobile app to the site ( login - registration - profile - CRUD )
If I divide API and web routes should I write two times my application and I think that in this way I can miss some functionalities but if it the best way to do it I will.
I think ideally you'll want dedicated api routes that use similar functionality. What that might look like in practice would be stripping logic out of your controllers into reusable traits so that your controller methods simply call the appropriate trait method to get data, and the controller responds either with a view template for your existing routes or with json for new api routes.
As for authentication, you'll likely want to use something like JWT
If you want to add an API to your app then add routes and controllers. You canât âmagicallyâ create an API from web controllers because youâre unlikely to have a one-to-one mapping between web and API functionality. Think of a home page. Itâs probably going to query and display multiple types of models, so isnât going to map to a single, resourceful API endpoint nicely.