slim4 / gslim-skeleton
slim 4 微服务骨架
v1.1.0
2021-04-14 08:20 UTC
Requires
- doctrine/doctrine-bundle: ^2.3
- doctrine/orm: ^2.8
- dragonmantank/cron-expression: ^3.0
- guzzlehttp/guzzle: ^7.2
- illuminate/database: ^7.12
- justinrainbow/json-schema: ^5.2
- monolog/monolog: ^2.0
- php-amqplib/php-amqplib: ^2.11
- php-di/php-di: ^6.1
- phpunit/phpunit: ^8.5
- slim/csrf: ^1.1
- slim/http: ^1.2
- slim/psr7: ^1.3
- slim/slim: ^4.0
- symfony/console: ^5.0
- symfony/serializer: ^5.2
- uma/dic: ^1.0
- vlucas/phpdotenv: ^5.3
- vlucas/valitron: ^1.4
Requires (Dev)
- symfony/var-dumper: ^5.2
This package is auto-updated.
Last update: 2024-09-15 21:25:08 UTC
README
使用 Slim PHP 微框架进行 JSON schema 验证的 RESTful API 开发的有用框架。
使用技术:“PHP 7, Slim 4, MySQL, Doctrine, PHPUnit, dotenv & vagrant”。
⚙️ 快速安装
要求
- Composer。
- PHP 7.2+。
- MySQL/MariaDB。
- 或 Vagrant。
使用 Composer
您可以通过运行以下命令创建一个新项目
$ composer create-project slim4/gslim-skeleton [my-app]
配置您的 MySQL 服务器连接
默认情况下,API 使用 MySQL 数据库。
您应该在您的 scr/Config/.env
文件中检查并编辑此配置
APP_URL=http://yourproject.lo/
APP_DEBUG=true
APP_ID=1
APP_ENV=local
#Database
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=gslim
DB_USERNAME=vagrant
DB_PASSWORD=vagrant
DB_CHARSET=utf8
DB_COLLATION=utf8_unicode_ci
DB_PREFIX=
# Cache twig
CACHE=false
#LOG_PATH
LOG_PATH='storage/logs/app.log'
📦 依赖项
依赖项列表
- slim/slim: Slim 是一个 PHP 微框架,可以帮助您快速编写简单而强大的 Web 应用程序和 API。
- slim/psr7: 用于 Slim 4 的 PSR-7 实现。
- slim/csrf: Slim 框架 CSRF 保护。
- doctrine/orm: 对象关系映射器。
- justinrainbow/json-schema: PHP 的 JSON Schema。
- vlucas/phpdotenv: 自动将环境变量从
.env
加载到getenv()
、$_ENV
和$_SERVER
。
开发依赖项列表
- phpunit/phpunit: PHP 单元测试框架。
- symfony/console: 用于创建美观且可测试的命令行界面的组件。
PHP Slim 命令行:$ php slim
Slim Command Management Console 1.0 Usage: command [options] [arguments] Options: -h, --help Display help for the given command. When no command is given display help for the list command -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: help Display help for a command list List commands migrate Perform database migration make make:command Create command file make:controller Create interface controller make:entity Create Entity e. g. UserAccess = tablename user_access make:exception Create service interface make:middleware Create Middleware make:migration Create database migration file e. g. create_user_access_table / update_user_access_table make:service Create service interface make:trait Create interface trait migrate migrate:rollback Roll back the database migration schedule schedule:run Run timed task scheduling commands
🔖 端点
默认情况下
-
CSRF 令牌:
GET /api/token
-
健康检查:
GET /healthcheck
😎 就这么多!
现在开始构建一个酷炫的 SLIM API。