dotkernel / api
DotKernel API
Requires
- php: ~8.2.0 || ~8.3.0
- ext-gd: *
- ext-json: *
- dotkernel/dot-cache: ^4.0
- dotkernel/dot-cli: ^3.5.0
- dotkernel/dot-data-fixtures: ^1.2.2
- dotkernel/dot-dependency-injection: ^1.0
- dotkernel/dot-errorhandler: ^4.0.0
- dotkernel/dot-mail: ^4.1.1
- dotkernel/dot-response-header: ^3.2.3
- laminas/laminas-component-installer: ^3.4.0
- laminas/laminas-config: ^3.9.0
- laminas/laminas-config-aggregator: ^1.14.0
- laminas/laminas-http: ^2.19.0
- laminas/laminas-hydrator: ^4.15.0
- laminas/laminas-inputfilter: ^2.29.0
- laminas/laminas-paginator: ^2.18.0
- laminas/laminas-stdlib: ^3.19.0
- laminas/laminas-text: ^2.11.0
- mezzio/mezzio: ^3.19.0
- mezzio/mezzio-authentication-oauth2: ^2.8.0
- mezzio/mezzio-authorization-acl: ^1.10.0
- mezzio/mezzio-authorization-rbac: ^1.7.0
- mezzio/mezzio-cors: ^1.11.1
- mezzio/mezzio-fastroute: ^3.11.0
- mezzio/mezzio-hal: ^2.9
- mezzio/mezzio-problem-details: ^1.13.1
- mezzio/mezzio-twigrenderer: ^2.15.0
- ramsey/uuid-doctrine: ^2.1.0
- roave/psr-container-doctrine: ^5.2.1
- symfony/filesystem: ^7.0.3
- zircote/swagger-php: ^4.10
Requires (Dev)
- laminas/laminas-coding-standard: ^2.5
- laminas/laminas-development-mode: ^3.12.0
- mezzio/mezzio-tooling: ^2.9.0
- phpunit/phpunit: ^10.5.10
- roave/security-advisories: dev-latest
- vimeo/psalm: ^5.22.0
This package is auto-updated.
Last update: 2024-09-13 13:08:07 UTC
README
基于Enrico Zimuel的Zend Expressive API - 框架示例,DotKernel API在Laminas和Mezzio组件上运行,并实现了PSR-3、PSR-4、PSR-7、PSR-11和PSR-15等标准。
入门指南
步骤1:克隆项目
使用您的终端,导航到您想要下载项目文件的目录中。在下载过程中,请确保目录为空。一旦到达那里,请运行以下命令
git clone https://github.com/dotkernel/api.git .
步骤2:安装项目依赖
composer install
步骤3:开发模式
如果您正在为开发安装项目,请确保已启用开发模式,通过运行以下命令
composer development-enable
您可以通过运行以下命令来禁用开发模式
composer development-disable
您可以通过运行以下命令来检查您是否已启用开发模式
composer development-status
步骤4:准备配置文件
- 将
config/autoload/cors.local.php.dist复制为config/autoload/cors.local.php<- 如果您的API将由另一个应用程序消费,请确保配置allowed_origins - 将
config/autoload/local.php.dist复制为config/autoload/local.php - 将
config/autoload/mail.local.php.dist复制为config/autoload/mail.local.php<- 如果您的API将发送电子邮件,请确保填写SMTP连接参数 - 可选:为了运行/创建测试,将
config/autoload/local.test.php.dist复制为config/autoload/local.test.php<- 这将在内存中创建一个新的数据库,您的测试将在该数据库上运行
步骤5:设置数据库
运行迁移
-
创建一个新的MySQL数据库 - 设置校对为
utf8mb4_general_ci -
在
config/autoload/local.php中的$databases['default']下填写数据库连接参数 -
通过以下命令运行数据库迁移
php vendor/bin/doctrine-migrations migrate
此命令将提示您确认是否运行它
WARNING! You are about to execute a migration in database "..." that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
按Enter键确认操作。
执行固定值
固定值用于在数据库中填充初始值,应在迁移数据库后执行。
要列出所有固定值,请运行
php bin/doctrine fixtures:list
这将按执行顺序输出所有固定值。
要执行所有固定值,请运行
php bin/doctrine fixtures:execute
要执行特定固定值,请运行
php bin/doctrine fixtures:execute --class=FixtureClassName
有关固定值如何工作的更多详细信息,请参阅此处:https://github.com/dotkernel/dot-data-fixtures#creating-fixtures
步骤6:测试安装
php -S 0.0.0.0:8080 -t public
向主页发送GET请求应输出以下消息
{
"message": "DotKernel API version 5"
}
文档
要访问DotKernel API文档,请检查提供的readme文件。
此外,每个CLI命令都有自己的文档