Search code examples
phprestzend-framework2zend-studiolaminas-api-tools

How / Why does the dummy Apigility REST application wotk without end points?


The video tutorial "Apigility Integration in Zend Studio" shows an example of Apigility application building in Zend Studio. It's an example for RPC.

Now I created a project based on the "Simple Services" template (New -> Project... -> Apigility Project -> Simple Services). A simple Zend Framework 2 RESTful Apigility application was created. But I cannot understand how/why.

Usually in Apigility applications the "controller functionality" is / the end points are implemented in the Resource classes, right? But the dummy Zend Studio application does not provide any Resource class -- and it works without it. How is it possible / does it work?


Solution

  • The Apigility documentation (REST Service Tutorial -> Create a REST Service -> [infobox] Code-Connected vs DB-Connected services) provides the perfect answer:

    Code-Connected vs DB-Connected services

    When you create a Code-Connected service, Apigility creates a stub "Resource" class that defines all the various operations available in a REST service. These operations return 405 Method Not Allowed responses until you fill them in with your own code. The "Code-Connected" aspect means that you will be supplying the code that performs the actual work of your API; Apigility provides the wiring for exposing that code as an API.

    DB-Connected services allow you to specify a database adapter and a table; Apigility then creates a "virtual" Resource which delegates operations to an underlying Zend\Db\TableGateway\TableGateway instance. In other words, it is more of a rapid application development (RAD) or prototyping tool.