Laravel is a web application framework with expressive, elegant syntax. It attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching.

Laravel is a great fit for building JSON APIs, this is due to the thriving package community, extensive documentation and the ease and simplicity of setting up and getting started on a Laravel project. This post will offer a step by step guide on how to use Laravel by our technical development experts.

Getting Started With Laravel

The majority of the boilerplate code needed to write a JSON API is included in the Dingo API package. To begin, run the following commands:

composer create-project --prefer-dist laravel/laravel my-json-api
composer require dingo/api:1.0.x@dev

Next you will need to add the service providers so Dingo can hook into your Laravel application:

'providers' => [
    Dingo\Api\Provider\LaravelServiceProvider::class
]

Finally one more command needs to be run:

php artisan vendor:publish --provider="Dingo\Api\Provider\LaravelServiceProvider"

Building Your First Endpoint