定制 manianrezaei/laravel-light-api 二次开发

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

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

manianrezaei/laravel-light-api

最新稳定版本:0.1.0

Composer 安装命令:

composer require manianrezaei/laravel-light-api

包简介

Create automatic light api for laravel

README 文档

README

The Laravel Light API package is designed to assist users in creating APIs for all Models in Laravel. With this package, you can easily generate API routes for your models, saving you time and effort.

Installation

To install the package, run the following command in your Laravel project:

$ composer require manianrezaei/laravel-light-api

Once the package is installed, you can start using it by following these steps:

  1. Publish package vendors:

    $ php artisan vendor:publish

then select package provider ManianRezaei\LaravelLightApi\providers\ApiLightServiceProvider

  1. Optimize the API routes using the following command:

      $ php artisan optimize 
  2. Thats it! You now have API routes and controllers set up for all your models.

Usage

Laravel Light Api endpoint is /apilight by default

To change the endpoint and configure the accessable models, see the config/apilight.php .

Set the base endpoint:

 'endpoint' => "/apilight",

List of models can access by api

'permissions'=>[
       "usr"=> [
            "model"=> \App\Models\User::class,
            "allowlist" =>[
                'id',
                'updated_at',
                'created_at'
            ]
        ]
    ]

"Permissions" contains an array of models that are allowed in LightAPI.

To keep the models' names hidden, you can specify an alias. In the example above, "usr" is an alias for the User model, and the endpoint for this model will be /apilight/usr.

All selectable fields should be added to the allowlist.

Custom selection

By default, LightAPI selects all whitelisted fields in each query.

Selected fields can be specified in the query string like this:

/apilight/usr?select=id,created_at

Contributing

If you would like to contribute to this package, feel free to fork the repository on GitHub and submit a pull request. We welcome any contributions and appreciate your support.

License

This package is open-source and released under the MIT License. Feel free to use, modify, and distribute it as per the terms of the license.

For more information, please refer to the GitHub repository.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固