pop-api / api-rest
在 PoP API 中创建 REST 端点
Requires
- php: ^8.1
- pop-api/api-mirrorquery: ^5.0
Requires (Dev)
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^10.2
- rector/rector: ^0.18
- squizlabs/php_codesniffer: ^3.6
Conflicts
- gatographql/external-dependency-wrappers: <5.0.0
- gatographql/gatographql: <5.0.0
- gatographql/plugin-utils: <5.0.0
- gatographql/testing-schema: <5.0.0
- getpop/access-control: <5.0.0
- getpop/cache-control: <5.0.0
- getpop/component-model: <5.0.0
- getpop/componentrouting: <5.0.0
- getpop/definitions: <5.0.0
- getpop/dom-crawler: <5.0.0
- getpop/engine: <5.0.0
- getpop/engine-wp: <5.0.0
- getpop/engine-wp-bootloader: <5.0.0
- getpop/filestore: <5.0.0
- getpop/graphql-parser: <5.0.0
- getpop/guzzle-http: <5.0.0
- getpop/loosecontracts: <5.0.0
- getpop/mandatory-directives-by-configuration: <5.0.0
- getpop/markdown-convertor: <5.0.0
- getpop/root: <5.0.0
- getpop/root-wp: <5.0.0
- graphql-by-pop/graphiql: <5.0.0
- graphql-by-pop/graphql-clients-for-wp: <5.0.0
- graphql-by-pop/graphql-endpoint-for-wp: <5.0.0
- graphql-by-pop/graphql-request: <5.0.0
- graphql-by-pop/graphql-server: <5.0.0
- graphql-by-pop/graphql-voyager: <5.0.0
- phpunit-for-gatographql/dummy-schema: <5.0.0
- phpunit-for-gatographql/dummy-wp-schema: <5.0.0
- phpunit-for-gatographql/gatographql: <5.0.0
- phpunit-for-gatographql/gatographql-testing: <5.0.0
- phpunit-for-gatographql/webserver-requests: <5.0.0
- phpunit-for-gatographql/wpfaker-schema: <5.0.0
- pop-api/api: <5.0.0
- pop-api/api-clients: <5.0.0
- pop-api/api-endpoints: <5.0.0
- pop-api/api-endpoints-for-wp: <5.0.0
- pop-api/api-graphql: <5.0.0
- pop-backbone/php-hooks: <5.0.0
- pop-backbone/wp-data-parser: <5.0.0
- pop-cms-schema/categories: <5.0.0
- pop-cms-schema/categories-wp: <5.0.0
- pop-cms-schema/category-mutations: <5.0.0
- pop-cms-schema/category-mutations-wp: <5.0.0
- pop-cms-schema/comment-mutations: <5.0.0
- pop-cms-schema/comment-mutations-wp: <5.0.0
- pop-cms-schema/commentmeta: <5.0.0
- pop-cms-schema/commentmeta-wp: <5.0.0
- pop-cms-schema/comments: <5.0.0
- pop-cms-schema/comments-wp: <5.0.0
- pop-cms-schema/custompost-categories-wp: <5.0.0
- pop-cms-schema/custompost-category-mutations: <5.0.0
- pop-cms-schema/custompost-category-mutations-wp: <5.0.0
- pop-cms-schema/custompost-mutations: <5.0.0
- pop-cms-schema/custompost-mutations-wp: <5.0.0
- pop-cms-schema/custompost-tag-mutations: <5.0.0
- pop-cms-schema/custompost-tag-mutations-wp: <5.0.0
- pop-cms-schema/custompost-tags-wp: <5.0.0
- pop-cms-schema/custompost-user-mutations: <5.0.0
- pop-cms-schema/custompost-user-mutations-wp: <5.0.0
- pop-cms-schema/custompostmedia: <5.0.0
- pop-cms-schema/custompostmedia-mutations: <5.0.0
- pop-cms-schema/custompostmedia-mutations-wp: <5.0.0
- pop-cms-schema/custompostmedia-wp: <5.0.0
- pop-cms-schema/custompostmeta: <5.0.0
- pop-cms-schema/custompostmeta-wp: <5.0.0
- pop-cms-schema/customposts: <5.0.0
- pop-cms-schema/customposts-wp: <5.0.0
- pop-cms-schema/media: <5.0.0
- pop-cms-schema/media-mutations: <5.0.0
- pop-cms-schema/media-mutations-wp: <5.0.0
- pop-cms-schema/media-wp: <5.0.0
- pop-cms-schema/menus: <5.0.0
- pop-cms-schema/menus-wp: <5.0.0
- pop-cms-schema/meta: <5.0.0
- pop-cms-schema/metaquery-wp: <5.0.0
- pop-cms-schema/page-mutations: <5.0.0
- pop-cms-schema/page-mutations-wp: <5.0.0
- pop-cms-schema/pagemedia-mutations: <5.0.0
- pop-cms-schema/pages: <5.0.0
- pop-cms-schema/pages-wp: <5.0.0
- pop-cms-schema/post-categories: <5.0.0
- pop-cms-schema/post-categories-wp: <5.0.0
- pop-cms-schema/post-category-mutations: <5.0.0
- pop-cms-schema/post-mutations: <5.0.0
- pop-cms-schema/post-tag-mutations: <5.0.0
- pop-cms-schema/post-tags: <5.0.0
- pop-cms-schema/post-tags-wp: <5.0.0
- pop-cms-schema/postmedia-mutations: <5.0.0
- pop-cms-schema/posts: <5.0.0
- pop-cms-schema/posts-wp: <5.0.0
- pop-cms-schema/queriedobject: <5.0.0
- pop-cms-schema/queriedobject-wp: <5.0.0
- pop-cms-schema/schema-commons: <5.0.0
- pop-cms-schema/schema-commons-wp: <5.0.0
- pop-cms-schema/settings: <5.0.0
- pop-cms-schema/settings-wp: <5.0.0
- pop-cms-schema/tag-mutations: <5.0.0
- pop-cms-schema/tag-mutations-wp: <5.0.0
- pop-cms-schema/tags: <5.0.0
- pop-cms-schema/tags-wp: <5.0.0
- pop-cms-schema/taxonomies: <5.0.0
- pop-cms-schema/taxonomies-wp: <5.0.0
- pop-cms-schema/taxonomy-mutations: <5.0.0
- pop-cms-schema/taxonomy-mutations-wp: <5.0.0
- pop-cms-schema/taxonomymeta: <5.0.0
- pop-cms-schema/taxonomymeta-wp: <5.0.0
- pop-cms-schema/taxonomyquery: <5.0.0
- pop-cms-schema/taxonomyquery-wp: <5.0.0
- pop-cms-schema/user-avatars: <5.0.0
- pop-cms-schema/user-avatars-wp: <5.0.0
- pop-cms-schema/user-roles: <5.0.0
- pop-cms-schema/user-roles-wp: <5.0.0
- pop-cms-schema/user-state: <5.0.0
- pop-cms-schema/user-state-mutations: <5.0.0
- pop-cms-schema/user-state-mutations-wp: <5.0.0
- pop-cms-schema/user-state-wp: <5.0.0
- pop-cms-schema/usermeta: <5.0.0
- pop-cms-schema/usermeta-wp: <5.0.0
- pop-cms-schema/users: <5.0.0
- pop-cms-schema/users-wp: <5.0.0
- pop-schema/directive-commons: <5.0.0
- pop-schema/extended-schema-commons: <5.0.0
- pop-schema/http-requests: <5.0.0
- pop-schema/schema-commons: <5.0.0
- pop-wp-schema/block-content-parser: <5.0.0
- pop-wp-schema/blocks: <5.0.0
- pop-wp-schema/commentmeta: <5.0.0
- pop-wp-schema/comments: <5.0.0
- pop-wp-schema/custompostmeta: <5.0.0
- pop-wp-schema/customposts: <5.0.0
- pop-wp-schema/media: <5.0.0
- pop-wp-schema/menus: <5.0.0
- pop-wp-schema/meta: <5.0.0
- pop-wp-schema/multisite: <5.0.0
- pop-wp-schema/pages: <5.0.0
- pop-wp-schema/posts: <5.0.0
- pop-wp-schema/schema-commons: <5.0.0
- pop-wp-schema/settings: <5.0.0
- pop-wp-schema/site: <5.0.0
- pop-wp-schema/taxonomymeta: <5.0.0
- pop-wp-schema/usermeta: <5.0.0
- pop-wp-schema/users: <5.0.0
- dev-master / 5.0.x-dev
- 5.0.0
- 4.2.0
- 4.1.1
- 4.1.0
- 4.0.1
- 4.0.0
- 3.0.0
- 2.6.1
- 2.6.0
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 1.6.0
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.10
- 0.9.9
- 0.9.8
- 0.9.7
- 0.9.6
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.9
- 0.8.8
- 0.8.7
- 0.8.6
- 0.8.5
- 0.8.4
- v0.8.3
- v0.8.2
- 0.8.1
- 0.7.13
- 0.7.12
- 0.7.11
- 0.7.10
- 0.7.9
- 0.7.8
- 0.7.7
- 0.7.6
This package is auto-updated.
Last update: 2024-09-07 03:39:08 UTC
README
它允许添加 REST 端点以检索任何基于 URL 资源的数据。它基于 PoP API 包。
安装
通过 Composer
composer require pop-api/api-rest
开发
源代码托管在 GatoGraphQL monorepo 中,位于 API/packages/api-rest
。
启用美观的永久链接
Apache
确保 Apache 服务器已安装并启用了 proxy
和 proxy_http
模块。这启用了以下重写规则中的配置 "P"
在 "[L,P,QSA]"
。
在 .htaccess
中添加以下代码以支持资源页面 URL 结尾的 API 端点 /api/rest/
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Rewrite from /some-url/api/rest/ to /some-url/?scheme=api&datastructure=rest RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)/api/rest/?$ /$1/?scheme=api&datastructure=rest [L,P,QSA] </IfModule>
Nginx
在 Nginx 配置的 server
条目中添加以下代码以启用 API 端点 /api/rest/
。请注意,以下解析器是 Docker 的;请根据您的环境替换此值。
location ~ ^(.*)/api/rest/?$ { # Resolver for Docker. Change to your own resolver 127.0.0.11 [::1]; # If adding $args and it's empty, it does a redirect. # Then, add $args only if not empty set $redirect_uri "$scheme://$server_name$1/?scheme=api&datastructure=rest"; if ($args) { set $redirect_uri "$scheme://$server_name$1/?$args&scheme=api&datastructure=rest"; } proxy_pass $redirect_uri; }
用法
初始化组件
\PoP\Root\App::stockAndInitializeModuleClasses([([ \PoPAPI\RESTAPI\Module::class, ]);
将 /api/rest/
添加到 URL 以获取预定义字段。
PHP 版本
需求
- 开发需要 PHP 8.1+
- 生产需要 PHP 7.2+
支持的 PHP 功能
检查 GatoGraphQL/GatoGraphQL 中的支持 PHP 功能列表
预览降级到 PHP 7.2
通过 Rector (dry-run 模式)
composer preview-code-downgrade
标准
要检查编码标准,请运行 PHP CodeSniffer
composer check-style
要自动修复问题,请运行
composer fix-style
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
测试
要执行 PHPUnit,请运行
composer test
静态分析
要执行 PHPStan,请运行
composer analyse
报告问题
要报告错误或请求新功能,请在本包的 GatoGraphQL monorepo 问题跟踪器 上操作。
贡献
我们欢迎在本包上对 GatoGraphQL monorepo (本包源代码托管处) 的贡献。
请参阅 CONTRIBUTING 和 CODE_OF_CONDUCT 以获取详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件发送至 leo@getpop.org,而不是使用问题跟踪器。
致谢
许可协议
GNU通用公共许可证第2版(或更新版)。有关更多信息,请参阅许可文件。