slim4/gslim-skeleton

slim 4 微服务骨架

v1.1.0 2021-04-14 08:20 UTC

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”。

Software License

⚙️ 快速安装

要求

  • 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'

📦 依赖项

依赖项列表

开发依赖项列表

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。