
Welcome to this course on REST API's for Laravel. This is a quick introduction before we dive in!
We get started with a blank Laravel application and make sure our development server is up and running. With this being done we are ready to develop the project!
We will set up the first RESTful route of our application. First, we will create a Task model and make sure that we can run database migrations. With this being done we can return a JSON response from our controller.
In this video, we learn about Laravel's built-in way of how we can represent database models as a resource in our API. Instead of returning a JSON response from our API, we will use these resource classes to manage the response from our controller.
In this video, we learn about how to keep our routes files comprehensive using resources routes. This keeps our code clean and take full advantage of Laravel.
In this video, we learn about how to send POST requests to our API and create new Task models. We will take advantage of Laravel's request validation to make sure we don't try to store faulty Task models in our database.
Now that we know about request validation and creating resources we can go one step further; and also learn about updating resources. For this, we set up a new method in our TaskController and use Postman to update an existing resource using an HTTP PUT request.
To finalize the CRUD actions that we can perform on a resource we still need the ability to delete a resource via our API. That's what we will take a look at in this last video of the section.
Now that we can perform basic CRUD operations with our API it's time to build on this foundation. The first thing we will take a look at is extending our Task collection response with pagination.
In this video, we start with a more complex operation on our resource collection, namely filtering the Tasks via our API. For this, we will require the 3rd party Laravel Query Builder package.
With the Query Builder package we installed in the previous video, we can implement sorting, besides filtering. We will allow sorting tasks on multiple properties in our API.
A crucial part of API’s is authentication. In this video, we get started with authentication with API tokens by using the Laravel Sanctum package.
We will properly configure Laravel Sanctum and set up a controller to manage authentication. With this being done we can retrieve an API token for our user.
We learn to use Laravel middleware to require authentication for certain routes. These protected routes will require an API token before we can retrieve data. To make sure we can't retrieve data that we shouldn't see we implement a global scope for the Task model.
Now that we can sign in with a user via API tokens, we can associate models to the currently authenticated user. We will set the creator of a Task model to the signed-in user by using the Laravel Auth facade.
In the previous videos we did set up the logic for authentication, but so far we don't allow new users to register for our application. We will implement a controller method for registration in this video.
In this section we will get deeper intro relationships in Laravel. Before we can get started we have some preparation to do. In this video we will add a Project model, to which we will attach tasks.
With our newly created Project model, we can group tasks by project. However, our API does not allow for creating and updating projects. We will set up resource routes and implement the controller actions to do so in this video.
Next we will take a look at how we can create a relationship between tasks and projects via our API. For this, we allow to send a project_id for task request and use Laravel Validation to make sure we don't send invalid project ID's.
We get started with our first nested REST resource. We set up the routes and implement the first controller action.
Now that we defined our first nested resource we can utilize this to attach users as a member to projects.
Last but not least, let's implement a controller action to remove members from a project.
In this section, we will get started with testing our API with PHPUnit. But first things first, we will make sure that we have the proper configuration set up in this video before we dive in.
In this course you'll learn how to create a REST API using the web framework PHP. If you wish to build an app or single-page application with a backend system, the go to way is building REST API's. Luckily we don't have to reinvent the wheel. Popular web frameworks, like Laravel, allow us to quickly build amazing REST API's.
During this course we take a project-based approach to learning about REST API's using Laravel. We will build an API for a task manager. This will demonstrate the most common problems you'll experience during the development of your own REST API.
During this course you will learn the following:
Implement CRUD actions for REST Resources in Laravel.
Make HTTP Requests using Postman.
User authentication with Laravel Sanctum using API tokens.
Sorting, Filtering and Pagination of lists of resources using the Laravel Query Builder package.
About Me
My name is Koen, it is nice to meet you. Starting out at the age of 15 with iOS development I never lost my interest in Software Development. Currently I mainly keep myself occupied with web development. I am invested in multiple backend technologies and frameworks, such as Ruby on Rails, Django and Laravel. On the frontend side of projects I follow the development of React, Alpine.js and Vue.js closely.