@samdark I have another idea about REST but I’m not sure if it is good or not for a Yii hackathon so I’ll just throw it here because I also need your feedback about it.
I like using the basic template for REST. I keep the
web folder as it is to be able to use gii to generate models, views, … the generated web controllers are useful to quickly add/update data and it is always useful to keep access to gii as you may need it later.
Then I build an
api folder for REST with its own entry script, config file, routing rules, modules, controllers, some models,… (exactly as it is done in this tutorial) and when the app should go to production I just delete the
web folder and keep only the
api folder (+ an
auth folder which role is deliver refresh and access tokens but that is a different story).
Recently I found this great extension: https://github.com/zhuravljov/yii2-rest so I started thinking about this: why not building a custom template for REST where the
web folder is entirely used to build and debug the REST api then remove it when the REST app is production ready. the
web folder in this case should be a built-in application that does the following:
1- has a built-in actions (or custom version of gii) to generate the
api folder and related modules (v1,V2,…), config file…
2- has built-in actions to build resources on the fly (which means creating tables into database, maybe also generating migration scripts, controllers, models,…) and actions to add/update/delete data. the full picture can be seen by watching the first minute of this video which gives a preview of how deployd works. the idea is to do almost the exact same within a Yii web app.
3- uses the yii2-rest extension to debug the api BUT the debugger tool bar should not debug the
web folder related app. somehow it should collect and preview logs related to the
About 3 I don’t know if it is possible using the current yii2-debug extension and knowing that session should be disabled in the api related config file (at least when production ready). and this is why I’ll be grateful if I get your feedback about it so I may try doing it myself if it is possible but out of the Yii hackathon.