simianbv/json-schema
Composer 安装命令:
composer create-project simianbv/json-schema
包简介
A utility package for creating JSON resources based on the laravel models provided, comes with a model generator and migration
关键字:
README 文档
README
A JSON Schema generator for Laravel models
Installation
To install, use:
composer require simianbv/json-schema --dev
next up;
artisan vendor:publish --provider="Simianbv\JsonSchema\JsonSchemaServiceProvider" --tag=json-schema-stubs
artisan vendor:publish --provider="Simianbv\JsonSchema\JsonSchemaServiceProvider" --tag=json-schema
to get the stubs, next up;
define your YAML
The YAML definitions are ready to be served and used to create models, controllers, resources and in the future, filters.
Role: # the name of the model namespace: Acl # Define the relative namespace timestamps: true # Allow timestamps for the model softDelete: true # Allow softdeletes columns: # Define your columns id: # The name of the column type: bigInteger # The column type primary: true # Whether it's primary unsigned: true # Should be unsigned name: # The name of the column type: string # The column type nullable: false # Nullable or not length: 50 # The length of the column unique: true # Whether it should be unique relations: # Define the relations Group: # The name of the related Model namespace: Acl # Define the related Model's namespace type: belongsToMany # Define the type of relation local: id # Define the primary key in the related model foreign: id # Define what the foreign key should be
Another example:
RoleUser: # The name of the pivot table namespace: Acl # The relative namespace pivot_only: true # Set to true if this is only a pivt table timestamps: true # Whether you want timestamps columns: # Define your columns id: # The name of the column type: bigInteger # The type primary: true # Primary yes or no unsigned: true # Whether is should be unsigned or not role_id: # The name of the column ( note the _id ) type: bigInteger # The column type nullable: false # Nullable yes or no user_id: # The name of the column ( note the _id ) type: bigInteger # The column type nullable: false # Nullable yes or no relations: # The relations Role: # The name of the related Model namespace: Acl # The relative namespace this model resides in type: hasOne # The relation type local: role_id # The local key ( note the _id ) foreign: id # The foreign table's primary key User: # The name of the related Model namespace: # The namespace can be left blank type: hasOne # The Relation type local: user_id # The local column foreign: id # The foreign model's column
To define the JSON Schema, a Resource class is generated in the /app/Resources/Json/ directory
where you can define the schema further. You can add layout elements to wrap them inside or align them
horizontally or vertically.
simianbv/json-schema 适用场景与选型建议
simianbv/json-schema 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.79k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「json-schema」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 simianbv/json-schema 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 simianbv/json-schema 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 simianbv/json-schema 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Like FormRequests, but for validating against a json-schema
Extension for Opis JSON Schema
generate json schema files from openapi paths
JSON Schema builder and validator for MCP tool definitions
Immutable JSON Schema implementation with support for drafts 2020-12, 2019-09, draft-07, draft-06, and draft-05
Bridge to AMQP extension for PHP 7.1+ (incl. PHP 8) with support for annotations and JSON Schema
统计信息
- 总下载量: 2.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-12