定制 develings/api-x 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

develings/api-x

Composer 安装命令:

composer require develings/api-x

包简介

Create a full-fledged API using a simple json file.

README 文档

README

Logo

Build Status Total Downloads Latest Stable Version License

BE CAREFUL

This package is still under heavy development and may contain breaking changes with every update.

About

Create a full-fledged API only using a simple JSON file.

Search

Search should be easy

{ "name": "string|search:like" },
{ "description": "string|search:like_left" },
{ "description": "string|search:like_right" },
{ "uuid": "string|search:equal" },

Simple example

{
    "name": "App",
    "version": "1.0",
    "description": "A demo application using the ApiX library",
    "endpoint": "/api/v1.0/",
    "authentication": "token:users,api_key",
    "events": true,
    "db": {
        "driver": "mariadb",
        "prefix": "app_test_"
    },
    "servers": [
        {
            "url": "http://app.test"
        },
        {
            "url": "https://someId.execute-api.eu-central-1.amazonaws.com/dev"
        }
    ],
    "api": [
        {
            "name": "device",
            "timestamps": true,
            "soft_deletes": true,
            "identifier": "uuid",
            "sort_key": "created_at",
            "per_page": 10,
            "fields": {
                "uuid": "string|primary|default:uuid",
                "device_id": "string:64|unique",
                "last_active_at": "datetime|index|on_update_fill:datetime",
                "device_user_id": "uuid|nullable",
                "api_key": "string|default:alphanumeric,36"
            },
            "relations": {
                "user": "belongsTo:users"
            }
        }
    ]
}

We currently support the normal laravel DB drivers.

This definition will create an OpenAPI specification route plus a migration for the device table including the endpoints for it.

All that needs to be done is to instantiate the API class.

Install

You just need to require the composer package, and you're done.

composer install develings/api-x

Create api.json in the root of your project.

php artisan api:make

Instantiate

// add this to config/app.php
'providers' => [
    ...
    \ApiX\ApiXServiceProvider::class,
],

// add the route (e.g. routes/web.php)
$api = new ApiX\ApiX(base_path('api.json'));
$api->setRoutes();

Fake data

Since we have all the definition we need from the api.json file, it's also possible to populate test data using the faker package. Coming soon

Planned features

Use route syntax to fetch code from PHP instead of api.json. Eg:

{
    "api": [
        "@App\\ApiX\\DeviceAPI",
        "@App\\ApiX\\UserAPI:getDefinition",
        {
            "name": "company",
            "fields": "@App\\ApiX\\CompanyAPI:getFields"
        }
    ]
}

统计信息

  • 总下载量: 577
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固