common-gateway / t-junction-bundle
创建 symfony flex bundles 插件的示例包
Requires
- php: >=7.4
- commongateway/corebundle: ^1.0.6
Requires (Dev)
- symfony/dependency-injection: ~3.4|~4.1|~5.0
README
此包旨在将传入的消息导向正确的 commonground-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
创建您的 Bundle
本节是为希望构建插件以扩展 Common Gateway 功能而不添加到核心代码库的开发者而设计的。
以下知识是假设的或已安装的
Composer Packagist Docker Schema.json 对 Common Gateway 的基本了解
使用此模板
此模板用于快速开发 Symfony Bundle,并作为自定义插件的模型。按照以下步骤,在 45 分钟或更短的时间内创建您的插件
-
登录到 GitHub
-
使用 此模板
-
命名您的 Bundle(驼峰式)。根据 Symfony 命名约定,包名需要以
Bundle
结尾。 -
点击绿色按钮
从模板创建仓库
-
更新文件名和命名空间以适应您的需求
- 打开 composer.json,并将其名称更改为适合您的名称。第一个单词应该是命名空间,第二个是包名。
注意:这是短横线连接符形式。也请参阅:命名您的包
- 检查自动加载字段是否已相应设置。
- 打开 PetStoreBundle.php 并将 Bundle
name
和namespace
更改为适合您的名称。命名空间应与composer.json
中的包名相同,但为驼峰式。因此,common-gateway/pet-store-bundle
变为CommonGateway/PetStoreBundle
- 相应地重命名
/Service
和/ActionHandler
(或如果未使用则删除)。 - 将
/DependencyInjection/PetStoreExtension.php
重命名为您的BundleNameExtension.php
- 重命名
/Resources/config/services.yaml
命名空间
添加模式
您可以从您的 json 模式 中将实体加载到 /Schema
文件夹中,以便在 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
一旦将模式添加到存储库中,您还可以添加这些模式的对象/数据。示例在 /Data
文件夹中。