uni-method/

symfony-bundle

本包最新版本(0.1.7)没有提供许可证信息。

Jsonapi symfony实现包

安装: 53

依赖者: 0

建议者: 0

安全: 0

星标: 4

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

0.1.7 2022-11-27 22:53 UTC

This package is auto-updated.

Last update: 2024-09-28 02:48:05 UTC


README

请确保已全局安装Composer,具体安装方法请参考Composer文档中的安装章节

使用Symfony Flex的应用程序

打开命令行,进入您的项目目录并执行

$ composer require uni-method/symfony-bundle

未使用Symfony Flex的应用程序

步骤1:下载Bundle

打开命令行,进入您的项目目录并执行以下命令以下载此Bundle的最新稳定版本

$ composer require uni-method/symfony-bundle

步骤2:启用Bundle

然后,通过将其添加到项目config/bundles.php文件中注册的Bundle列表来启用该Bundle

// config/bundles.php

return [
    // ...
    UniMethod\Bundle\UniMethodBundle::class => ['all' => true],
];

步骤3:Bundle选项

如果不存在,创建config/packages/uni_method.yaml

uni_method:
  default_path: '%kernel.project_dir%/config/jsonapi' # path to entities config
  prefix: 'v' # prefix for version forexample /v1/user/
  available: # all available versions
    - 1 # version (subfolder in default_path)

步骤4:创建第一个版本(v1)

# config/jsonapi/1/config.yml
entities:
  user:
    class: 'App\Entity\User'
    description: 'Just a user'
    attributes:
      id:
        getter: 'getId()'
        type: integer
      email:
        getter: 'getEmail()'
        type: string
paths:
  -
    item: user
    method: list

步骤5:启用Bundle路由

# config/routes.yaml

app_extra:
  resource: .
  type: extra