common-gateway/zgw-vrijbrp-request-bundle

创建 symfony flex 插件包的示例

0.0.17 2024-09-12 10:02 UTC

README

此存储库用于创建 PHP Symfony flex 插件包。Common Gateway 生态系统使用此模板进行快速开发,以扩展 Core 之外的 Gateway 功能。

第一部分关于安装插件。后一部分关于自定义插件以扩展 Common Gateway 功能。

使用 Common Gateway 管理用户界面进行安装

一旦正确设置包(如此存储库),Common Gateway 可以在不进行额外配置的情况下发现该包。转到“插件”选项卡以搜索、选择和安装插件。

使用 PHP 命令安装

要执行以下命令,您需要 Composer 或已安装 PHP 和 Composer 的 dockerized 安装。

终端和根目录中的 Composer 方法

用于安装插件

$composer require common-gateway/pet-store-bundle:dev-main

用于安装模式

$php bin/console commongateway:install common-gateway/pet-store-bundle

终端和根目录中的 dockerized 方法

用于安装插件

$docker-compose exec php composer require common-gateway/pet-store-bundle:dev-main

用于安装模式

$docker-compose exec php bin/console commongateway:install common-gateway/pet-store-bundle

创建您的包

本节面向想要构建插件以扩展 Common Gateway 功能而不向核心代码库添加代码的开发者。

以下知识假设和/或已安装

使用此模板

此模板用于快速开发 Symfony 插件包,并作为基于您的自定义插件的基础模型。按照以下步骤,在 45 分钟或更短的时间内创建您的插件

  1. GitHub 上登录

  2. 使用 此模板

  3. 命名您的包(驼峰式)。包名需要以 Bundle 结尾,符合 Symfony 命名约定

  4. 点击绿色按钮 从模板创建存储库

  5. 更新文件名和命名空间以适应您的情况

    • 打开 composer.json,并将其名称更改为您适合的。第一个单词应该是命名空间,第二个是包名。

    注意:这是中划线命名法。还要阅读: 命名您的包

    • 检查自动加载字段是否已正确设置。
    • 打开 PetStoreBundle.php,并将 Bundle namenamespace 更改为适合您的。命名空间应与 composer.json 中的包名相同,但使用驼峰式。因此,common-gateway/pet-store-bundle 变为 CommonGateway/ZgwVrijBRPRequestBundle
    • 相应地重命名 /Service/ActionHandler(如果未使用则删除)。
    • /DependencyInjection/PetStoreExtension.php 重命名为您的 BundleNameExtension.php
    • 重命名 /Resources/config/services.yaml 命名空间

添加模式

您可以从您的 json schemas 文件夹中加载实体,用于在 Common Gateway 中使用,并根据您的模式处理对象。

您可以向 /Schema 文件夹中添加现有模式或创建自己的模式并将其添加进去。这里有一个示例,见 /Schema/example.json

以下属性是必需的,没有它们,网关不会识别模式为有效

- `version` can start on '0.1.0.' 

没有这个属性,您无法更新方案

- `$schema` (https://docs.commongateway.nl/schemas/Entity.schema.json)
- `$id` (https://example.com/schema/{Your scheme name}.schema.json)

唯一的 $id 可以与其他模式关联。

- `type` must be 'object'
- `properties` must be schema properties

一旦您将模式添加到存储库,您还可以为这些模式添加对象/数据。示例见 /Installation/Data 文件夹。