O'Reilly logo

Web Application Development with Yii 2 and PHP by Jeffrey Winesett, Mark Safronov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building the API module

We have two controller actions currently in our system, which:

  • Are not needed for the user interface
  • Provide the API-like representation of the information in the system

All this makes these actions perfect targets for our practice in building modules. Let's make an API module that will contain the actions currently reachable by the /services/json and /services/yaml routes.

The following use cases should be supported:

  • The GET request to the /api/services/json route should return the list of attributes of all registered services in the JSON format
  • The GET request to the /api/services/yaml route should return the list of attributes of all registered services in the YAML format

We define result in JSON format as the string that can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required