sioweb / oxid-api
基于 Symfony 的 API
0.4.2
2020-06-15 05:14 UTC
Requires
- php: ^7.0
- oxid-community/symfony-kernel: *
- sioweb/ccevent-git: *
- symfony/security-bundle: ~3.1.0
README
前言
这个 API 正在建设中,如果安装了 API,任何人都可以访问您的文章和分类。我建议不要在实时环境中使用 - 即使它能工作 - 直到可以使用 Secret Key 或 HTTP 密码进行认证 认证请见下文。
开发,分支
该项目可以在 GNU LGPL 3+ 的意义上进行分支、开发和分发。免费。为了避免并行开发,我建议我们在本存储库中进行开发。我乐意接受反馈、问题和建议。
安装
composer req sioweb/oxid-api
安装后,必须在 Oxid 后端激活模块 Sioweb | Oxid Kernel
和 Sioweb | Oxid Symfony API
。
为什么要这样做?
是的,确切地说。一个基于 Symfony 的 REST API,具有真正的路由,并以 JSON 格式输出信息。
认证
现在所有路由都可以通过 HTTP 认证使用。只需提供 Oxid 用户名和密码即可。
现在还需要单独保护路由,并应实现 Token 登录。
路由
以下 Routes
提供结果
在控制台中使用 Curl: curl -k -H "X-AUTH-TOKEN: THIS_IS_A_TOKEN" https://deine-url/api/v1/article/
文章
- https://deine-domain.tld/api/v1/article/ [GET]
- https://deine-domain.tld/api/v1/article/{item}/ [GET]
分类
- https://deine-domain.tld/api/v1/category/ [GET]
- https://deine-domain.tld/api/v1/category/{item}/ [GET]
以下 Routes
将会在未来实现
- https://deine-domain.tld/api/v1/article/ [POST]
- https://deine-domain.tld/api/v1/article/{item}/ [PUT]
- https://deine-domain.tld/api/v1/article/{item}/ [DELETE]
- https://deine-domain.tld/api/v1/category/ [POST]
- https://deine-domain.tld/api/v1/category/{item}/ [PUT]
- https://deine-domain.tld/api/v1/category/{item}/ [DELETE]
- https://deine-domain.tld/api/v1/order/ [GET]
- https://deine-domain.tld/api/v1/order/ [POST]
- https://deine-domain.tld/api/v1/order/{item}/ [GET]
- https://deine-domain.tld/api/v1/order/{item}/ [PUT]
- https://deine-domain.tld/api/v1/order/{item}/ [DELETE]
- https://deine-domain.tld/api/v1/user/ [GET]
- https://deine-domain.tld/api/v1/user/ [POST]
- https://deine-domain.tld/api/v1/user/{item}/ [GET]
- https://deine-domain.tld/api/v1/user/{item}/ [PUT]
- https://deine-domain.tld/api/v1/user/{item}/ [DELETE]
- https://deine-domain.tld/api/v1/{_url_fragment}
为什么不用GraphQL?
没有原因。我认为GraphQL更加灵活和优秀——为什么不使用一个固定的REST模型,即使有一个查询语言呢。我习惯于使用REST API,只是通过一些与MongoDB等相关的Angular项目积累了GraphQL的经验。