Web Development


RESTful API with Laravel: Build a Real API with Laravel

Build a RESTful API for a market system using Laravel and dominate the most challenging features of APIs with Laravel

4.22 (1017 reviews)



15 hours


Jun 2020

Last Update
Regular Price

What you will learn

Create your own projects with Laravel (not only RESTful APIs)

Make the most of your work tools (Sublime Text 3, Git, Github, Composer, PHP artisan and Laravel)

Generate and maintain the structure of the database in an automated way with Laravel and the PHP Artisan console

Use PHP Artisan effectively and be much more efficient

Create and configure your own local development environment

Properly configure your development environment for all your projects

Hone the main HTTP methods/verbs for HTTP and RESTful APIs

Use free professional tools to improve your productivity


So you need to build a RESTful API for a project, but you do not know even where to start? Do not worry I will guide you through the whole process to build a genuine RESTful API using Laravel.

Join the more than 5.000 students already taking this course, building their RESTful APIs using Laravel, and enjoying every single class!

Note: You can take, and in fact it is recommended, to follow the course using the most recent version of Laravel. Additionally, the course includes extensive sections about how to upgrade your project to different versions of Laravel, in case you decide to use any previous version.

Build your RESTful API with Laravel, using a complete marketplace as the case of use. With Laravel, creating every component will be a breeze. You will have a project with users, sellers, buyers, transactions, products, and categories. Explore all types of relationships, one to many, many to many and much much more using Eloquent the Laravel ORM.

The full guide for creating a real RESTful API with Laravel. You can follow the course using the latest Laravel version (it is recommended).

You will not find a Laravel course like this. This course explains everything you need to develop a RESTful API using the Laravel framework.

At the end of the course, you will have a RESTful API with Laravel, for a market system, where users can purchase and sell different products with different categories and transactions. Inclusive, the same user can be both a seller and a buyer (you will take advantage of inheritance for this).

¡Do Not wait anymore! Become a master in the development of genuinely RESTful APIs with Laravel. Join the course now and see you in class

Remember: The course has been constantly updated to use the latest versions of Laravel. So feel free to use the version you like (especially the latest version of Laravel).

In this course, you learn how to develop a realistic,  fully implemented, and professional RESTful API with Laravel.

Laravel is the most popular PHP framework, with more than 20 million downloads along with lots of enterprise and personal projects worldwide. Additionally, it includes fantastic features to implement a RESTful API easily. Laravel is RESTful friendly.

What is a RESTful API?
A Web API is like a web service that works entirely with HTTP. A RESTful API must follow the REST (REpresentational State Transfer) practices, allowing to orientate the design to the resources, provide standard responses based on the different HTTP status codes, and the corresponding according to Hypermedia Links in responses (HATEOAS).

Why Laravel?
Because Laravel is a framework made by programmers for programmers, expressive, simple, intuitive, and powerful. Laravel provides useful features for web projects including RESTful APIs.

Each new Laravel version includes many changes that make this framework even better, simple, programmer-friendly, and at the same time much more powerful. In fact, the latest versions of Laravel included a lot of new features to help to develop RESTful APIs in the right way.

During this course, you will master the complete structure of Laravel, along with the new features included in the latest version of Laravel to develop an actual RESTful API.

You will learn this about the development of a RESTful API with Laravel:

  • Using the Laravel PHP artisan for code and components generation

  • Usage and creation of middleware on Laravel

  • The Laravel Resource routes and controllers (ideal for RESTful APIs)

  • Fully supported JSON format responses for a JSON RESTful API

  • Validation of requests directly from the Laravel Controllers

  • Handling all types of exceptions and errors from Laravel handler

  • Complex operations involving up to three resources/models for a specific operation

  • Usage of Laravel dependency injection and model binding

  • Generation of the database structure using Laravel migrations

  • Automatic insertion of fake data into the database through "faker," using Laravel factories, and seeders

  • Laravel Sessions and access_token authentication for the RESTful API. Yes, Both!

  • Using Laravel Passport to protect the RESTful API with OAuth2

  • Pagination of results using Laravel collections

  • Using URL parameters to execute actions (the RESTful approach)

  • Sorting results based on URL parameters with a RESTful approach

  • Filtering results using URL parameters

  • Caching responses using Laravel Cache System

  • Limitation of requests using the Laravel middleware

  • Implementing HATEOAS on Laravel (a pure RESTful API must use HATEOAS)

  • Using PHP Fractal for transforming responses

  • Usage of CORS on the API responses to allow JavaScript-based clients and web browsers.

  • Use the Laravel Policies and Gates to handle the user's authorization layer.

  • Much more!!

You can take a look at the full list of contents below. You will finish with a complete RESTful API and understanding a lot of Laravel skills.

You will create an actual RESTful API from scratch and step by step using Laravel. Follow the REST architecture and build appropriate URLs to identify actions and resources using the Laravel best features and learn Laravel in the way.

Take full advantage of tools like Sublime Text 3, Git, power shell, Laravel, Composer, PHP artisan, and be more productive for agile development.

Note: In few classes of the course I use Windows (only for the first classes), but I included specific directions in the case you use Linux or Mac and all the tools used are cross-platform, so you will no have any problem.

You will have lifetime access to the current classes and the classes that I will regularly add (take a look at the last section to see what is coming).

At the end of this course, you will be able to develop your pure RESTful API with Laravel in an efficient way with the best practices, taking advantage of the facilities provided by Laravel for the proper implementation of your projects and your RESTfulAPI.

Do not wait any longer. Join the course and see you in classes.


RESTful API with Laravel: Build a Real API with Laravel
RESTful API with Laravel: Build a Real API with Laravel
RESTful API with Laravel: Build a Real API with Laravel
RESTful API with Laravel: Build a Real API with Laravel



About the Instructor and the Course

Taking Advantage of the Course and Contents

Downloading and Installing the Tools to Develop the RESTful API with Laravel

Downloading and Installing PHP with XAMPP

Downloading and Installing Composer

Downloading and Installing Virtual Box

Downloading and Installing Vagrant

Downloading and Installing Sublime Text 3

Downloading and Installing Github Shell

Downloading and Installing Node and NPM

Downloading and Installing Postman to Test the Laravel RESTful API

Creating and Setting the Initial Structure of Laravel for the RESTful API

Obtaining Laravel Using Composer

Adding Laravel Homestead as a Dependency for The Laravel Project

Laravel 6 additional step

Preparing and Configuring Laravel Homestead

Adding the Virtual Domain on The System

Using Vagrant to Manage the Laravel Homestead Virtual Machine

Exercise Find out how to go out from the Virtual Machine

Keep The Laravel Project Updated

Configuring and Using Sublime Text 3 to Develop the RESTful API with Laravel

Installing the Package Control

Creating and Using Projects

Installing and Using SublimeCodeIntel to Resolve Laravel and RESTful API classes

Installing and Using SideBarEnhancement

Installing and Using SublimeLinter for PHP

Installing and Using PHPCompanion to Auto-import Laravel Definitions

Understanding the Case Study for the RESTful API

Understanding the RESTful API Resources (Models) and its Relationships

Understanding the Main End-Points for the RESTful API

Discovering and Configuring the Laravel Structure for the RESTful API

Discovering the Laravel Structure

Discovering the Laravel PHP Artisan Commands

Configuring the Laravel Environment Variables

Understanding the Laravel Routes System for RESTful APIs

Creating the Initial Laravel Components for the RESTful API

How to Solve Common Errors During the Development of the RESTful API

Creating Initial Laravel Structures for The Models and Its Migrations

Creating an Initial Laravel Structure for The Controllers

Creating Some End-Point for the RESTful API Using Laravel Resource Routes

Implementing the RESTful API Models and its Relationships using Laravel Eloquent

Implementing The Properties for Category

Implementing The Properties for Product

Implementing The Properties for Transaction

Implementing The Properties for User

Implementing The Relationships Between Models

Creating the Database Structure Using Migrations from Laravel

Solving a Common Issue with the Laravel Migrations

Implementing The Migration for Users

Implementing The Migration for Categories

Implementing The Migration for Products

Implementing The Migration for Transactions

Creating the Migration for The Pivot Table

Creating the Laravel Factories for Database Seeding

Creating The Laravel Factory for User

Creating The Factory for Category

Creating The Factory for Product

Creating The Factory for Transaction

Using The Factories from The DatabaseSeeder of Laravel

Executing The Migrations and Seeder using Artisan from Laravel

Implementing the Operations for UserController

Implementing The Index Method for UserController

Implementing The Show Method for UserController

Implementing The Store Method for UserController

Implementing The Update Method for UserController

Implementing The Destroy Method for UserController

Implementing the operations for Buyer

Implementing The Index Method for BuyerController

Implementing The Show Method for BuyerController

Implementing the operations for Seller

Implementing The Index Method for SellerController

Implementing The Show Method for SellerController

Improving the current RESTful API operations

Defining Mutators and Accessor for Models

Generalizing The Response Methods

Using The Generalized Methods

Using The Generalized Methods for Error Responses

Handling Errors and Exceptions with the Laravel Handler

Returning Validation Errors as a JSON Response

Returning Model Not Found Errors as a JSON Response

Handling AuthenticationException

Handling AuthorizationException

Handling NotFoundHttpException

Handling MethodNotAllowedHttpException

Handling General HttpException

Catching Exceptions When Removing Related Resources

Handling Unexpected Exceptions

Implicit Model Binding with Routes and Methods

Using The Laravel Implicit Model Binding for Some Methods

Resolving Buyer Using Laravel Global Scopes

Resolving Seller Using Laravel Global Scopes

Implementing Soft Deleting for All the Models

Modifying the Migrations for Soft Deleting

Using soft Deleting for All the Models

Implementing the Operations for Category

Implementing the Index Method for CategoryController

Implementing the Show Method for CategoryController

Implementing the Store Method for CategoryController

Implementing the Update Method for CategoryController

Implementing the Destroy Method for CategoryController

Implementing the Operations for Product

Implementing the Index Method for ProductController

Implementing the Show Method for ProductController

[Exercises] Implementing the Operations for Transaction

Implementing the Index Method for TransactionController

Implementing the Show Method for TransactionController

Implementing Complex Operations within Transaction

Implementing the Index Method for TransactionCategoryController

Implementing the Index Method for TransactionSellerController

Implementing Complex Operations for Buyer

Implementing the Index Method for BuyerTransactionController

Implementing the Index Method for BuyerProductController

Implementing the Index Method for BuyerSellerController

Implementing the Index Method for BuyerCategoryController

Implementing Complex Operations for Category

Implementing the Index Method for CategoryProductController

Implementing the Index Method for CategorySellerController

Implementing the Index Method for CategoryTransactionController

Implementing the Index Method for CategoryBuyerController

Removing the Pivot Table from the Results

Implementing Complex Operations for Seller

Implementing the Index Method for SellerTransactionController

Implementing the Index Method for SellerCategoryController

Implementing the Index Method for SellerBuyerController

Implementing the Index Method for SellerProductController

Implementing the Store Method for SellerProductController

Implementing the Update Method for SellerProductController

Implementing the Destroy Method for SellerProductController

Implementing Complex Operations for Product

[Challenge] Implementing the Index Operation of ProductTransaction

[Challenge] Implementing the Index Operation of ProductBuyer

[Challenge] Implementing the Index Operation of ProductCategory

Implementing the Update Operation of ProductCategory

Implementing the Destroy Operation of ProductCategory

Implementing the Store Operation for ProductBuyerTransaction

Handling the Products Availability Using Events

Adding an Image for Products

Preparing the API for Images Uploading

Storing an Image When Creating a Product

Removing the Image When Deleting a Product

Updating the Image When Editing a product

Sending Email for Users Accounts Verification

Preparing the Laravel Project for Email Sending

Implementing the Verification System

Creating the Laravel Mailable for User Created

Implementing the UserCreated Mailable

Send Verification Email Using Events

Solving the Problem with Factories

Creating the Mailable for User Mail Changed

Implementing the UserMailChanged Mailable

Send Verification for Email Changed Using Events

Re-sending the Verification Email If Requested

Dealing with Failing-Prone Actions

Using Laravel Markdown Mailables

The Middleware and the Rate Limiting

About the Middleware and How it Works in Laravel

Creating a Custom Middleware

About the Rate Limiting in Laravel and the Details

[Optional] Customizing the Response for “Too Many Attempts”

Transforming Responses with PHP Fractal for Security and Compatibility

About Transformers and Why to Use It

Preparing the Laravel Project for Data Transforming

Creating the Transformer for User

Creating the Transformer for Seller and Buyer

Creating the Transformer for Category

Creating the Transformer for Transaction

Creating the Transformer for Product

Linking the Models with its Respective Transformer

Returning the New Transformed Responses

Sorting and Filtering Results Based on Query Parameters

Sorting Results by Any Attribute

Understanding an Issue with Sorted Responses

Improving the Transformations to Solve the Problem

Implementing the Solution Using Transformers

Filtering Responses Based on Attributes

Pagination of Results

About Pagination

Paginating Already Built Collections

Allowing Custom Page Size

Caching Results with Laravel Cache System

Implementing the Cache System

The Caching System and the Query Parameters

Implementing HATEOAS Hypermedia Controls

What is and Why to Use HATEOAS

Implementing HATEOAS Hypermedia Controls for Category Instances

Implementing HATEOAS Hypermedia Controls for Product Instances

Implementing HATEOAS for Transaction Instances

Implementing HATEOAS for User Instances

[Exercise] Implementing HATEOAS for Buyer

[Exercise] Implementing HATEOAS for Seller

The Transformations and the Validations

Understanding Two Problems with Transformations and Validations

Creating and Using a Middleware to Solve the Problem

Solving the First Problem Using the Middleware

Improving the Transformations to Solve the Second Problem

Improving the Middleware to Solve the Second Problem

Preparing the API for User Authentication Using Sessions

Why is It Required for Our API

Laravel 6: Before to continue...

Creating the Additional Authentication Structure

Tuning Some Structures to Avoid Inconsistences

About CSRF and Handling CSRF Exceptions in Laravel

Returning HTML and Redirections When Required

Using Laravel Passport to Implement the Initial Security Layer with OAuth2

About OAuth2 and Security on APIs

What is Laravel Passport

Preparing the Laravel Project to Use Laravel Passport

Using the Migrations of Laravel Passport

Installing Laravel Passport Definitively on the API

Making Users Authenticatable Through API Tokens

Registering the Required Routes

Configuring the Authentication System

Defining the Expiration Time for the Tokens

Using client_credentials Grant to Protect Some Routes

How to Obtain and Use Tokens Using Client Credentials

Protecting All the Routes

Using the Password Grant Type

Preparing the API to Use the Passport Components

Creating the Views to Manage the Personal Tokens

About the Personal Tokens and How to Use It

Allowing the Management of API Clients

About the Authorization Code Grant Type

Using the Implicit Grant Type

Refreshing Tokens

Restricting OAuth2 Clients Using Scopes

What are Scopes on OAuth2?

Registering Some Required Scopes for the API

Registering the Laravel Passport Middleware to Check Scopes

Restricting the Action that Needs the “purchase-product” Scope

Restricting the Actions that Need the “manage-products” Scope

Restricting the Actions that Need the “manage-account” Scope

Restricting the Actions that Need the “read-general” Scope

Implementing the Final Security Layer Using Policies and Gates of Laravel

About the Final Security Layer

What are Policies and Gates on Laravel?

Implementing the Restrictions Over Buyer

Implementing the Restrictions Over Seller

The Restrictions over User

Implementing the Restrictions Over Transaction

Implementing the Restrictions Over Product

Allowing All Actions for Admin Users

Allowing Remaining Actions ONLY Admin Users Can Do

CORS for Laravel

About CORS

Installing the CORS Package for Laravel

Configuring the CORS Package

Allowing CORS Only for the API

Allowing CORS on Error Responses Too

Additions and Fixes for the Laravel RESTful API

Identifying an Authenticated User in the RESTful API

[Optional] Upgrading to Laravel 5.5

About the Upgrading Process to Laravel 5.5

Upgrading to Laravel 5.5 Along With Dependencies

Upgrading the Source Code According to Laravel 5.5

[Optional] Upgrading to Laravel 5.6

Preparing the Environment to Upgrade

Obtaining Laravel 5.6

Installing Updated Dependencies

Solving Issues and Updating the Project Structure

[Optional] Upgrading to Laravel 5.7

Preparing the development environment to upgrade

Installing Laravel 5.7 an upgrading dependencies for the RESTful API

Upgrading the components and structures

[Optional] Upgrading to Laravel 6

Upgrading the development environment

Obtaining Laravel 6 and upgrading the dependencies

Resolving the issues to use Laravel 6


List of Pending Topics

Thanks for Be Here!


Gonzalo1 October 2020

Well, Laravel is constantly upgraded, so, in September 2020, there is Laravel 8 and is worse, Laravel 5 of this course is using php 5.6, now we have php 7.4, so there is a lot of problem that it will bad here. For example, it is impossible to install laravel homestead with php5.6 and laravel in this course only works with php 5. Thanks to my knoweledge i keep studing but for sure a newbie will have a lot of problems and frustrations.

Yousef26 August 2020

The sound is very often overdriven that is just annoying. And sorry, but the accent is absolutely terrible, I would like to leave the course immediately. Only the content is convincing. Only the content alone has earned two and a half stars.

Daniel23 August 2020

the content of the course is rich, and well structured. However the strong accent makes it hard to follow. I'm come from a spanish speaking country so i had no problem following through. I do recomend improving your accent to take your clases to a whole new level, besides that it was an amazing experience, and i look forward to your next courses.

Linish11 July 2020

Awesome Class. Explained all concepts. Learned new things like Gates, Policies, Transformers Highly recommended!

Grigoriy9 July 2020

Almost no explanation of what is being done. You just repeat the code typed with no understanding. A lot of spam at the beginning of the videos.

Hugo23 February 2020

The instructor has a deep knowledge of the content covered, the accuracy of the information he teaches and the details can be seen, congratulations on the excellent course.

千葉21 February 2020

I'm Japanese. Eloquentの使い方がわかりました。テーブル設計含めて、「こうやって開発を進めるのか」という実感がわきました。 OAuthの部分は、何を目指した実装をしているのかがわかりにくいので、qiitaとかでOAuthとは何か、認可にはいくつかの種類があり、それぞれの仕組みを押さえておくと理解できると思います。 完全にはlaravel6向けにできていない部分もありますが、質問>現在のレクチャーを見ればたいてのことは解決できます。 あとは字幕。lecture120あたりから、全く意味をなさなくなります。それまでにはこの人の独特な発音には慣れているはずなので、外して聞くのが吉でしょう。

Kevin27 January 2020

Great course, instructor is very knowledgeable and walked through the steps for building a complete API from start to finish. The pace of the course was great and the short videos make it easy to go back and rewatch, knowing exactly where to find the content.

Ivan20 December 2019

Very nice and laconic course. Greate job done by JuanD MeGon! One of the best parts of this course - it is splitted on very short videos, which allow you to educatute yourself even if you have a lack of time. I highly recommend this course to whoever wants to upgrade his laravel coding skills. Definately will take another course of JuanD MeGon.

Scott11 December 2019

I am not using Homestead nor am I on a windows machine so this first section has not been very helpful

Andrey10 December 2019

Everything is okey except two aspects. First, I don't like an intro for each lesson with some wise phrases because this doesn't relate to a Laravel topic. Secondly, Lessons are two small and can be combines into one a bit bigger lesson

Deni27 October 2019

could only have shown more explicitly how to generate some tokens as admin or regular user and when changing grant_types in the generation of tokens, in some classes only showed the generated tokens, this may have confused some people

Michael9 October 2019

Great course. Incredibly comprehensive with each feature being explained in great detail, why, how, when, and where.

Volodymyr17 September 2019

The course is really comprehensive and covers so many features of Laravel in common that it will be exactly useful for every PHP developer preferring Laravel. Thanks to Juan for his amazing job and I am thinking about taking other courses created by Juan!

Gerrit16 September 2019

Very nice detailed course so far that will be my reference for future projects. Well done and thank you!


Udemy ID


Course created date


Course Indexed date
Course Submitted by

Android PlayStore
Apple Appstore