Giter Site home page Giter Site logo

laravel-1's Introduction

Tests

JSON:API for Web Artisans

Implement feature-rich JSON:API compliant APIs in your Laravel applications. Build your next standards-compliant API today.

Why use JSON:API?

  • Standardised, consistent APIs.
  • Feature rich - some of which are filtering, pagination, eager loading and sparse fieldsets.
  • Easy to understand.

Why use Laravel JSON:API?

  • Saves a lot of development time.
  • Highly maintainable code.
  • Great, extensive documentation.
  • Strong conventions, but also highly customisable.
  • Makes use of native Laravel features such as policies and form requests to make the shift easier for developers.
  • Beautiful, expressive Nova-style schemas.
  • Fully testable via expressive test helpers.
class PostSchema extends Schema
{

    /**
     * The model the schema corresponds to.
     *
     * @var string
     */
    public static string $model = Post::class;

    /**
     * The maximum include path depth.
     *
     * @var int
     */
    protected int $maxDepth = 3;

    /**
     * Get the resource fields.
     *
     * @return array
     */
    public function fields(): array
    {
        return [
            ID::make(),
            BelongsTo::make('author')->type('users')->readOnly(),
            HasMany::make('comments')->readOnly(),
            Str::make('content'),
            DateTime::make('createdAt')->sortable()->readOnly(),
            DateTime::make('publishedAt')->sortable(),
            Str::make('slug'),
            BelongsToMany::make('tags'),
            Str::make('title')->sortable(),
            DateTime::make('updatedAt')->sortable()->readOnly(),
        ];
    }

    /**
     * Get the resource filters.
     *
     * @return array
     */
    public function filters(): array
    {
        return [
            WhereIdIn::make($this),
            WhereIn::make('author', 'author_id'),
        ];
    }

    /**
     * Get the resource paginator.
     *
     * @return Paginator|null
     */
    public function pagination(): ?Paginator
    {
        return PagePagination::make();
    }
}

Documentation

See our website, laraveljsonapi.io

Tutorial

New to JSON:API and/or Laravel JSON:API? Then the Laravel JSON:API tutorial is a great way to learn!

Follow the tutorial to build a blog application with a JSON:API compliant API.

Installation

Install using Composer

composer require laravel-json-api/laravel

See our documentation for further installation instructions.

Upgrading

When upgrading you typically want to upgrade this package and all our related packages. This is the recommended way:

composer require laravel-json-api/laravel --no-update
composer require laravel-json-api/testing --dev --no-update
composer up laravel-json-api/* cloudcreativity/json-api-testing

Example Application

To view an example Laravel application that uses this package, see the Tutorial Application.

License

Laravel JSON:API is open-sourced software licensed under the Apache 2.0 License.

laravel-1's People

Contributors

lindyhopchris avatar x-coder264 avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.