Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Rest Api Laravel Package

birim/laravel-rest-api

Expose Eloquent models as a simple JSON REST API in Laravel. Configure endpoints in a config file, then query /laravel-json/{resource} for lists, skip/take pagination, and basic field search. Optionally control returned attributes via model properties.

View on GitHub
Deep Wiki
Context7

Laravel REST API

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui