定制 birim/laravel-rest-api 二次开发

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

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

birim/laravel-rest-api

最新稳定版本:v1.0.1

Composer 安装命令:

composer require birim/laravel-rest-api

包简介

Laravel REST API

README 文档

README

The Laravel REST API provides an interface for applications to interact with your application by sending and receiving data as JSON.

Installation

You can install the package via composer:

composer require birim/laravel-rest-api

You can publish the config file with:

php artisan vendor:publish --tag=laravel-rest-api

Configuration

First define the endpoints for your REST API in the configuration file. An endpoint contains a label and refers to an Eloquent class. Example:

<?php

return [
    'endpoints' => [
        'users' => App\Models\User::class
    ]
];

Routes

After configuration, the REST API endpoints can be called. All endpoints start with laravel-json.

Currently, three types of endpoints are provided: List, Pagination and Search.

URI Method Description
/laravel-json/users GET Get all users
/laravel-json/users/skip/0/take/10 GET Get users by skip and take
/laravel-json/users/search/name/john GET Get all users with the name john

All available endpoints can be accessed with /laravel-json

Response

Returned data can optionally be configured within the Eloquent Model files. The $restApiAttributes property defines all attributes that should be returned. Without this property all attributes will be returned. If you want to exclude only certain attributes, you can use the $restApiHidden property.

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ExampleModel extends Model
{
    public $restApiAttributes = [
        'name',
        'email'
    ];

    public $restApiHiddenAttributes = [
        'name'
    ];

Changelog

Please read CHANGELOG for more information of what was changed recently.

License

This project and the Laravel framework are open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-07