Open ximex opened 9 years ago
I have renamed this to be short. I think about this since several years and it would be a very nice und useful change. But since now I havn't the time to start with this.
If someone has the time and motivation than I will support this immediatly. It will be useful to start with one thing and not the whole program. Maybe the login could be a good beginning. If we have here an API than other programs could perform a login to Admidio very easy.
The backend should not be nodejs because therefore something must be installed on the server (as I understand). It could also be just PHP and all data that will be returned is JSON (maybe later we could also provide other formats).
I only mean that than it is possible to change also the backend and the whole thing would still work. Nodejs is only one example. The main backend would stay in PHP.
The problem with nodejs today is only that nearly no hoster provides nodejs. And only less people have a root server to install nodejs on their own. But there is no problem with nodejs and JSON. nodejs is javascript and JSON is a subset of javascript. So nothing would work better with JSON than nodejs. Working with nodejs is what i'm doing at work for about nearly a year ;-)
I think the same like you that we should start with the login and add more and more features. But i want to plan some things, like how the routes should look, or what authentication system we would use.
We (the company i work) are building a cloud system with REST-API in the last half year and i think, i could show you some best practise we learned. E.g we use JsonWebToken for the auth. (http://jwt.io/) For the API Documentation i would introduce you "swagger" (http://swagger.io/) Here a small doc of our service: https://gemodev.msgis.net/api/developer/
Another thing is: We should use the HTTP methods and response codes that are available. https://de.wikipedia.org/wiki/Hypertext_Transfer_Protocol#HTTP-Anfragemethoden https://de.wikipedia.org/wiki/HTTP-Statuscode#Liste_der_HTTP-Statuscodes E.g.: NO: GET /someApiRoute/user/12/delete YES: DELETE /someApiRoute/user/12 or NO: GET /someApiRoute/user/create -> StatusCode: 200 YES: POST /someApiRoute/user/ -> StatusCode: 201
The easiest way to auth would be the "basic auth". (https://en.wikipedia.org/wiki/Basic_access_authentication)
this looks like a very nice framework: http://www.slimframework.com/ i will look at it in detail in the next days
v2.0 requires PHP 5.3+ v3.0 requires PHP 5.5+ (in development)
PHP 5.4 Support end was 14.09.2015. (https://secure.php.net/supported-versions.php) So i think if we start with the rest api concept we should drop PHP 5.4 and use slimframework v3.0. The patterns are nearly the same as of express.js which is the very most popular rest api framework and works really nice. (already working about nearly a year with express.js) The documentation of v3.0 is here: http://www.slimframework.com/docs
We still could improve Admidio 3.x after the release (v4.0?) of the new version with the rest api. So one for the old way and backward compatibility and one new build from scratch
Other Frameworks we should look at:
I think routes should look like:
www.example.com/api/{apiVersion}/core/{...}.{format}
www.example.com/api/{apiVersion}/plugins/{pluginName}/{...}.{format}
{...} e.g. is user
Example:
GET www.example.com/api/4.0.1/core/user/5.json
Will get the user properties in JSON format for user with id=5
or
POST www.example.com/api/4.0.1/core/organization.json
Will create a new organization. Response in JSON
We could also drop the .json
part and use only json at the beginning.
+1
I've worked with Slim Framework V2.* on several projects and I can only recommend it, it's also really easy to get your head around.
Slim 3.0 Final released: http://www.slimframework.com/2015/12/07/slim-3.html
Slim 3.1 released: http://www.slimframework.com/2016/01/08/slim-3.1.0.html
I appreciate that you plan to use Swagger (Open API Spec)!
@deki look here: https://github.com/Admidio/admidio-api-php
Is there already an alpha implementation for it?
No. This is only a first concept
Is there any progress on this topic?
no AFAIK
"We are excited to announce the Slim 4.4.0 release." http://www.slimframework.com/2020/01/04/slim-4.4.0-release.html
Should not that framework + the API https://admidio.github.io/documentation/api-docs/
give the REST interface we want?
Split Admidio in Backend-REST-API and Frontend-Page, so the backend logic is completely separated from the design. The normal Frontend page and the Appmidio App e.g. access the same REST-API from ONE Backend. All the data is requested with REST calls (javascript) So we could change each part (Backend/Frontend). E.g. use nodejs with express.js as backend