When you first build an application, you'll most likely imagine how the user will interact with it and how it will be designed and structured for your content and features. However, there also comes a time when you'll want to expose certain functionality of your website as web services.
CakePHP comes well-prepared for this, so in this recipe, we'll look at how you can easily create a data-focused controller to serve certain functionality of your application via a service.
For this recipe, we'll start with a basic controller to serve as our endpoint. So, create a file named
app/Controller/ with the following content:
<?php App::uses('AppController', 'Controller'); class ApiController extends ...