I know this has a few people excited, but this is just a proposal. Before any development gets done, we’d like to get the functionalities right. The idea here is to be able to generate client code from the services. This starts with generating a class for each service that allows you to communicate with said service, minimizing the boilerplate code that you have to write. But it can go one step further: generating a full client project that allows you to consume and test the services.
Beyond simply saving time, this could be used in the following scenarios:
– trying out a new runtime or protocol. For example amfPHP is historically associated with Flash, but it would be totally possible to write an Android client template that would allow you to generate an Android client without any Android programming skills.
– Creating a backoffice for customers. Suppose you did this nice project with a CMS and your customer doesn’t like the backoffice because it is too generic. You can use amfPHP to expose the methods that the customer is interested in, generate a client, maybe skin it a bit and you’re done: a custom backoffice.
The service browser is already a starting point: it analyses available services, and allows you to consume them. It is however only fit for use by the developer, for two reasons:
– it is generated at each view, and therefore isn’t suited for production use.
– it can’t easily be customized.
So this is a proposal to refactor and expand the service browser. Please comment!
The service browser is no longer a plugin, rather it is made separate from the main library. It now works by consuming the dat a generated by a service that describes the other services, their names, their methods, parameters etc. For those of you who used amfPHP 1.9, this is more or less how it worked. Back then it was called the “discovery service”, so let’s keep that name for now.
Both the service browser and the code generator are contained in a new backoffice, where further administration and development tools can be added in future versions.
Scripts for generating code also use the discovery service. This code is divided into 2 parts: basic service consumption code, and the test project code.
Design goals are:
– at a click of a button you can either generate just the service consumption code for all the services available on the server, or the whole project with a simple UI allowing you to test your services.
– make updating the generated code once the server has changed easy.
– Easy to skin/customize generated project
Possible options for generation therefore include:
– just service consumption code/ whole test project
– generate a zip(useful when the server isn’t local)
– a choice of language /ide/protocol.
– Anything specific to the generator, for example “package”.
For those interested here’s a zip containing some code that could be generated. It’s a pure AS3 Flash Builder project, and you can build the FLA in src too. It allows you to test 2 methods on the ExampleService currently included in amfPHP. It’s far from definitive, the url to the server is hard coded, there’s a memory leak somewhere I have to track down, but it should be able to give you an idea of the possibilities.