common-gateway / pet-store-bundle
创建 symfony flex bundles 插件的示例包
Requires
- php: >=7.4
- common-gateway/customer-notifications-bundle: ^0.0.40 | < 1.0
- commongateway/corebundle: ^1.2.68 | <2.0
Requires (Dev)
- symfony/dependency-injection: ~3.4|~4.1|~5.0
- dev-main
- 0.0.85
- 0.0.84
- 0.0.83
- 0.0.82
- 0.0.81
- 0.0.80
- 0.0.79
- 0.0.78
- 0.0.77
- 0.0.76
- 0.0.75
- 0.0.74
- 0.0.73
- 0.0.72
- 0.0.71
- 0.0.70
- 0.0.69
- 0.0.68
- 0.0.67
- 0.0.66
- 0.0.65
- 0.0.64
- 0.0.63
- 0.0.62
- 0.0.61
- 0.0.60
- 0.0.59
- 0.0.58
- 0.0.57
- 0.0.56
- 0.0.55
- 0.0.54
- 0.0.53
- 0.0.52
- 0.0.51
- 0.0.50
- 0.0.49
- 0.0.48
- 0.0.47
- 0.0.46
- 0.0.45
- 0.0.44
- 0.0.43
- 0.0.42
- 0.0.41
- 0.0.40
- 0.0.39
- 0.0.38
- 0.0.37
- 0.0.36
- 0.0.35
- 0.0.34
- 0.0.33
- 0.0.32
- 0.0.31
- 0.0.30
- 0.0.29
- 0.0.28
- 0.0.27
- 0.0.26
- 0.0.25
- 0.0.24
- 0.0.23
- 0.0.22
- 0.0.21
- 0.0.20
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-featue/schema-to-puml
- dev-feature/xz-45/code-sniffer
- dev-MWest2020-patch-1
This package is auto-updated.
Last update: 2024-09-15 11:44:08 UTC
README
此存储库用于创建 PHP Symfony flex bundles。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
创建您的 Bundle
本节是为希望构建插件以扩展 Common Gateway 功能而无需添加核心代码库的开发者。
以下知识假定和/或已安装
- Composer
- Packagist
- Docker
- Schema.json
- 对 Common Gateway 及 Core Bundle 的基本知识
使用此模板
此模板用于快速开发 Symfony bundle,旨在作为自定义插件的基础模型。按照以下步骤在 45 分钟或更短的时间内创建您的插件
-
在 GitHub 上登录
-
使用 此模板
-
命名您的 Bundle(驼峰式)。根据 Symfony 命名约定,包需要以
Bundle
结尾。 -
按下绿色按钮
从模板创建存储库
-
更新文件名和命名空间以适应您的需求
- 打开 composer.json,并将名称更改为适合您的名称。第一个单词应该是命名空间,第二个是包的名称。
注意:这是破折号式。也请阅读:命名您的包
- 检查 autoload 字段是否已相应设置。
- 打开 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 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
文件夹中找到。