💛 Modern API development in Laravel. ✍️ Developed by Gentrit Abazi.

Overview

Introduction

Larapi is a package thats offers you to do modern API development in Laravel with support for new versions of Laravel.

Larapi comes included with...

  • Exception handler for APIs.
  • A Controller class that gives response, parse data for your endpoints.
  • A Repository class for requesting entities from your database.
  • Sorting.
  • Filtering.
  • Eager loading.
  • Pagination.
  • Selecting columns dynamically.
  • Selecting scopes dynamically.
  • Appends.
  • A class for making internal API requests.

Documentation

https://one2tek.github.io/larapi/

Comments
  • [2.x] Update check for filtering column from include

    [2.x] Update check for filtering column from include

    if we try to use the filter method on a column based on an included properties like this :

    {base_url}/users?filter[author.name]=Gentrit
    

    the current implementation will crash because author.name won't be in the $whiteListFilter. if we use this modification like this we can find a way to reuse properties :

    class User extends Model
    {
      use HasFactory;
    
      public function author()
      {
          return $this->belongsTo(Author::class);
      }
    
      public static $whiteListFilter = ['id', 'author'];
      public static $whiteListFilteType = [null, Author::class];
    }
    
    class Author extends Model
    {
      use HasFactory;
    
      public static $whiteListFilter = ['id', 'name'];
    }
    

    The checkFilterColumn will check the first part of the $colum variables (author.name => author) and then check the next part (name => name) against the Author::class

    Like this we can filter all properties and sub-properties.

    opened by Angelinsky7 15
  • Selecting specific fields when using a nested include

    Selecting specific fields when using a nested include

    Is it possible to select certain field when requesting nested includes, like so:

    include=country.continent

    Say i want to select the name and the related continent from the country only, how can this be achieved? Obviousling using something like include=country:name.continent doesn't work. Also i feel like this markup tends to get a little akward when selecting relations and also specific fields, I would suggest something like the following:

    include=country(name).continent

    Where everything between the parenthesis is related to selecting specific fields of a relation, and the dot notation is still used for querying the relation

    Normally when not using a nested include, selecting specific fields can be done like so:

    include=country:name

    help wanted 
    opened by JessengBijleng 4
  • (Suggestion) Use method in controller to parse 'limit' and 'page'

    (Suggestion) Use method in controller to parse 'limit' and 'page'

    Hi,

    In LaravelController, why not use a method for parsing the limit and page parameter? Currently the parameters to retrieve these values are hardcored, like so:

    $limit = $request->get('limit', $this->defaults['limit']);
    $page = $request->get('page', $this->defaults['page']);
    

    Say for example i don't want to use the 'limit' parameter to determine the number of results, but a 'per_page' parameter. Currently, to override this behaviour, a user would have to override the entire parseResourceOptions method.

    I would suggest changing this into the following lines:

    $limit = $this->parseLimit($request->get('limit', $this->defaults['limit']));
    $page = $this->parsePage($request->get('page', $this->defaults['page']));
    

    So in one of my controllers, i could easily override the behaviour by overriding the specific method; (example):

    protected function parseLimit(?int $limit)
    {
        return request()->get('per_page', $limit ?: 25);
    }
    

    Also, i would suggest the validateResourceOptions in LaravelController to be protected, since validation of pagination parameters may differ after overriding the default pagination parameters.

    opened by JessengBijleng 3
  • [Question] Filtering and the NOT operator

    [Question] Filtering and the NOT operator

    I've got a question about the NOT operator. Why do we need to pass a "strange" value to use the NOT operator :

    {base_url}/users?filter[columnName][operator][not]=value
    

    in this example i first thought that i could directly type [not] in the request url instead i need to use it like this :

    {base_url}/users?filter[name][eq][yes]=Alex
    

    to look for all user without a name = Alex

    can it be more like this ? (it would be more user friendly, no ?)

    {base_url}/users?filter[name][eq][not]=Alex
    

    Thanks for this package, really like it

    opened by Angelinsky7 1
  • 2.x

    2.x

    Dropped support to send array in include. Dropped support to send array in doesntHave. Dropped support to send array in has. Default sort by DESC. Dropped support to send array in withCount. Removed IDs mode. Removed Sideload mode. Dropped support to send array in scope. Dropped support to send array in append. Dropped support to send array in select. Removed Advanced Eager loading. Pagination now starts from 1 not from 0.

    New 
    opened by gentritabazi 0
  • [feature] Mulitple Filter/FilterByAnd/FilterByOr on the same property

    [feature] Mulitple Filter/FilterByAnd/FilterByOr on the same property

    Actually it's not possible to filter the same property, if we use the actual api only the last filter is used. For example :

    http://localhost:8080/api/items?filterByOr[code][ct]=A&filterByOr[code][ct]=B
    

    this will only consider filterByOr[code][ct]=B because of the way php handle array (and it's totally normal)

    To have multiple filters on the same property we could add this api :

    {base_url}/items?filterByOr[][code][ct]=A&filterByOr[][code][ct]=B
    

    like that we would have an array of filters : and thus the api would become :

    filter / filterByOr
    []
    [property]
    [operator]
    =
    VALUE
    

    and now the example in the doc with the filtering is correctly working :


    Filter all users whose name start with Gentrit or ends with Abazi.

    {base_url}/users?filterByOr[][name][sw]=Gentrit&filterByOr[][name][ew]=Abazi
    
    opened by Angelinsky7 0
Releases(2.0.11)
  • 2.0.11(Apr 20, 2022)

    What's Changed

    • Add Laravel 9 support by @IIVR in https://github.com/one2tek/larapi/pull/81

    New Contributors

    • @IIVR made their first contribution in https://github.com/one2tek/larapi/pull/81

    Full Changelog: https://github.com/one2tek/larapi/compare/2.0.10...2.0.11

    Source code(tar.gz)
    Source code(zip)
  • 1.2.7(Dec 10, 2021)

  • 2.0.10(Sep 10, 2021)

  • 2.0.9(Jun 22, 2021)

    2.0.9

    Added more valid syntax for $whiteListFilter #75 (Thanks to @Angelinsky7) 🎉.

    List of all valid syntax for $whiteListFilter:

    public static $whiteListFilter = ['*'];
    public static $whiteListFilter = ['id', 'title', 'author'];
    public static $whiteListFilter = ['id', 'title', 'author.*'];  
    

    Full Docs: https://one2tek.github.io/larapi/#/filtering?id=filtering

    Source code(tar.gz)
    Source code(zip)
  • 2.0.8(May 23, 2021)

  • 1.2.6(Mar 8, 2021)

    Select & Selects by default now contain '*' in order to select all fields from a table (useful when using Case functions with subqueries)

    Source code(tar.gz)
    Source code(zip)
  • 2.0.7(Feb 14, 2021)

  • 2.0.6(Jan 18, 2021)

  • 2.0.5(Jan 18, 2021)

  • 2.0.4(Jan 14, 2021)

  • 2.0.3(Jan 8, 2021)

  • 2.0.0(Dec 30, 2020)

    2.0.0

    • Dropped support to send array in include.
    • Dropped support to send array in doesntHave.
    • Dropped support to send array in has.
    • Dropped support to send array in withCount.
    • Removed IDs mode.
    • Removed Sideload mode.
    • Dropped support to send array in scope.
    • Dropped support to send array in append.
    • Dropped support to send array in select.
    • Removed Advanced Eager loading.
    • Pagination now starts from 1 not from 0.
    • Added default sort by DESC.

    Happy new year 🥂.

    Source code(tar.gz)
    Source code(zip)
  • 1.2.5(Dec 29, 2020)

  • 1.2.4(Dec 18, 2020)

  • 1.2.3(Dec 15, 2020)

  • 1.2.2(Dec 10, 2020)

  • 1.2.1(Dec 10, 2020)

  • 1.2.0(Dec 9, 2020)

  • 1.1.3(Nov 29, 2020)

  • 1.1.2(Nov 22, 2020)

    1.1.2

    1. Docs improved.
    2. Routes class renamed to ApiConsumerRouter.
    3. larapi-components config file renamed to larapi.
    4. Removed SlackFormatter.
    5. Removed RouteServiceProvider.
    6. Deleted TransactionalAwareEvents.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Nov 5, 2020)

    1.1.1

    1. Added docs for Appends (https://one2tek.github.io/larapi/#/appends).
    2. Added 2 new methods to sort data (https://one2tek.github.io/larapi/#/sorting).
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Nov 5, 2020)

  • 1.0.7(Nov 3, 2020)

  • 1.0.6(Oct 30, 2020)

    1.0.6

    Added different ways to select columns (0b7c85b).

    1. {routeUrl}?select=id,created_at
    2. {routeUrl}?selects=last_name,first_name

    Happy coding 🥂.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.5(Oct 26, 2020)

  • 1.0.4(Oct 16, 2020)

  • 1.0.3(Oct 8, 2020)

    1.0.3

    In ComponentMakeCommand:

    1. Removed unused variables (8d56da2).
    2. Removed unused classes (81145c5).
    3. Added support for Plural and Singular (93bf4a6).
    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Oct 6, 2020)

    1.0.2

    Method get replaced with getWithCount after create Service with command php artisan component:make {parent} {name} . Added more details for command php artisan component:make {parent} {name} README.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Oct 5, 2020)

    1.0.1

    Improved filters. Added method getWithCount. Added more Example filters to README. Added clauseOperator and or to Custom Filters. Removed join-columns from config file, replaced with filterRawJoinColumns in repositories. Improved Slack formatter.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Sep 26, 2020)

    1.0.0

    Improved filters, added full support for not (negative filter) in all operators. Added more details to readme.md. Added Scopes System including Local Scopes and Global Scopes. Added has to support Querying Relationship Existence. Added Advanced Eager loading. Added way to select columns dynamically.

    Source code(tar.gz)
    Source code(zip)
Modern version of pocketmine forms API, ported to PHP 8.0+ with high quality code and phpstan integration

forms Modern version of pocketmine forms API, ported to PHP 8.0+ with high quality code and phpstan integration Code samples ModalForm Using ModalForm

Frago9876543210 23 Nov 18, 2022
An SDK built to facilitate application development for Facebook Ads API.

Facebook Business SDK for PHP Introduction The Facebook Business SDK is a one-stop shop to help our partners better serve their businesses. Partners a

Meta 719 Dec 28, 2022
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and / or RESTful API

Luracast Restler ![Gitter](https://badges.gitter.im/Join Chat.svg) Version 3.0 Release Candidate 5 Restler is a simple and effective multi-format Web

Luracast 1.4k Dec 14, 2022
Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using laravel best practices.

Laravel API tool kit and best API practices Laravel api tool kit is a set of tools that will help you to build a fast and well-organized API using lar

Ahmed Esa 106 Nov 22, 2022
This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science courses and the like.

Simple PHP API v.1.0 This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science courses a

Edson M. de Souza 14 Nov 18, 2021
微信支付 API v3 的 PHP Library,同时也支持 API v2

微信支付 WeChatPay OpenAPI SDK [A]Sync Chainable WeChatPay v2&v3's OpenAPI SDK for PHP 概览 微信支付 APIv2&APIv3 的Guzzle HttpClient封装组合, APIv2已内置请求数据签名及XML转换器,应

null 275 Jan 5, 2023
This API provides functionality for creating and maintaining users to control a simple To-Do-List application. The following shows the API structure for users and tasks resources.

PHP API TO-DO-LIST v.2.0 This API aims to present a brief to consume a API resources, mainly for students in the early years of Computer Science cours

Edson M. de Souza 6 Oct 13, 2022
API documentation API SCB EASY APP

SCB-API-EASY V3.0 API documentation SIAM COMMERCIAL BANK PUBLIC COMPANY LTD. API SCB Easy V3 endpoint = https://fasteasy.scbeasy.link 1.0. Get balance

SCB API Esay team 2 Sep 28, 2021
Courier API adalah project API untuk mengetahui ongkos kirim Logistik-logistik pengiriman barang antar kota & International

Courier API Courier API adalah project API untuk mengetahui ongkos kirim Logistik-logistik pengiriman barang antar kota (dalam negeri) & International

Rangga Darmajati 2 Sep 24, 2021
LaraBooks API - Simple API for iOS SwiftUI app tests.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Konrad Podrygalski 1 Nov 13, 2021
Simple PHP API client for tube-hosting.com rest API

Tube-Hosting API PHP client Explanation This PHP library is a simple api wrapper/client for the tube-hosting.com api. It is based on the provided docu

null 4 Sep 12, 2022
Best resources restful api for developers (with JSON:API standar specification design)

List API Best resources restful api for developers (with JSON:API standar specification design). API Resource Endpoint Name Resource Description Al Qu

Noval 2 Jan 18, 2022
Chargebee API PHP Client (for API version 2 and Product Catalog version 2.0)

chargebee-php-sdk Overview This package provides an API client for Chargebee subscription management services. It connects to Chargebee REST APIs for

GLOBALIS media systems 8 Mar 8, 2022
GraphQL API to Studio Ghibli REST API

GhibliQL GhibliQL is a GraphQL wrapper to the Studio Ghibli REST API Usage First, you'll need a GraphQL client to query GhibliQL, like GraphQL IDE Con

Sebastien Bizet 8 Nov 5, 2022
A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.

Laravel Responder is a package for building API responses, integrating Fractal into Laravel and Lumen. It can transform your data using transformers,

Alexander Tømmerås 776 Dec 25, 2022
Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。

Thresh Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。 安装 $ composer require telstatic/thresh -vvv 功能 生成 Markdown 文档 生成 Postman 配置文件 生

静止 5 Jul 12, 2021
A simple way of authenticating your RESTful APIs with API keys using Laravel

ApiGuard This package is no longer maintained This package is no longer maintained as Laravel already has a similar feature built-in since Laravel 5.8

Chris Bautista 691 Nov 29, 2022
A RESTful API package for the Laravel and Lumen frameworks.

The Dingo API package is meant to provide you, the developer, with a set of tools to help you easily and quickly build your own API. While the goal of

null 9.3k Jan 7, 2023
A simple example of how to create a RESTful API in Laravel Framework 8.36.1.

FirstLaravel A simple example of how to create a RESTful API in Laravel Framework 8.36.1. I used Database sqlite because I wanted to deploy this proje

Max Base 4 Apr 16, 2021