Microservices With Lumen A Service Oriented Architecture

With Lumen by Laravel, build a complete set of PHP microservices and APIs and its security layers using Lumen and OAuth2

Last updated 2022-01-10 | 4.6

- Build multiple different microservices using Lumen de Laravel
- Create a service-oriented architecture from scratch using the Lumen microframework
- Implements a complete security system to control access to internal and external architectural services

What you'll learn

Build multiple different microservices using Lumen de Laravel
Create a service-oriented architecture from scratch using the Lumen microframework
Implements a complete security system to control access to internal and external architectural services
Feel confident to create and implement service-oriented architectures using Lumen de Laravel
Master the best practices of construction and implementation of a complete architecture oriented to services

* Requirements

* Have PHP installed (at least PHP 7.1 is recommended).
* A code editor or IDE of preference (any of your choice).
* General knowledge of PHP
* Basic knowledge of object-oriented programming
* Install Postman in the system (it will be used to check the operation of the services)

Description

Implement from scratch a complete service-oriented architecture with PHP, using Lumen by Laravel.

Lumen is a PHP microframework based on Laravel (a PHP framework), which makes it ideal to implement microservices along with rapid and light systems.

During this course, I will show you the whole process to implement a service-oriented architecture with PHP and using Lumen;  implementing a set of microservices and its interactions. Build the entire security and interaction systems between each microservice. All of that using PHP with Lumen.


So, do not wait any more, and enroll now :)


Why should you take this course?

  • Because it gives you a detailed view, as in no other course, of a service-oriented architecture that is fully functional and secured using PHP and Lumen.

  • Because you will be able and confident enough to implement your microservices and architectures using Lumen and PHP.

  • Because it not only shows you the benefits of microservices and their architectures but also shows you how to solve the challenges that microservices represents

  • Because it shows you how to secure all the microservices in the architecture and control the access to them


What will you be able to do at the end of the course?
In general, you will be able to implement any microservices architecture you need using PHP and Lumen. You will have a clear idea of ​​how to implement each microservice with Lumen, as well as how the interaction between each of these microservices should be structured, how to build a complete security layer that protects and restricts access to each microservice in the architecture using OAuth2 with Lumen/Laravel Passport along with authenticate users and use different grant types of OAuth2.

You will feel confident to take your path and carry out your projects with all the microservices and components you want with PHP and Lumen.


What will you learn exactly?

  • Create projects in Lumen by Laravel

  • Configure and use Lumen easily in your system without complex processes

  • Use Lumen properly for its ideal purpose: the microservices

  • Build a fully functional service-oriented architecture from scratch

  • Use OAuth2 to protect access to your architecture, through Lumen/Laravel Passport

  • Install and adapt Laravel Passport to Lumen projects

  • Create access tokens associated with users to handle users data and authorization flows

  • Authenticate users credentials and restrict access to only valid users if needed

  • Authorize and use different kinds of access tokens to restrict the action over your resources

  • Create a complete system of interaction between microservices through HTTP requests with GuzzleHTTP from Lumen

  • Build fully functional and adequate services with Lumen

  • Returns and builds standardized JSON responses with Lumen

  • Separate the components of a service-oriented architecture appropriately

  • Handle errors and exceptions appropriately to ensure the consistency of the entire architecture

  • Build and implement, correctly, an API Gateway for your architecture

  • Centralize the consumption of your service-oriented architecture through an API Gateway with Lumen

And a lot much more. You will have access for life to each class that makes up the course and those that will come later. You also have direct access to me, so you can ask me questions and solve all your doubts.

Do not wait any longer, cheer up and join the course and give free rein to all the possibilities that Lumen offers with a service-oriented architecture.

Who this course is for:

  • Who wants to start in the world of service-oriented architectures (SOA)
  • Who seeks to implement fast and light services using the Lumen microframework
  • Whoever wants to increase the scalability and maintainability of their projects with microservices
  • Whoever seeks to learn to create and use microservices in a complete architecture
  • Who seeks to dominate Lumen to implement microservices
  • Whoever wants to learn how to use Lumen to build complete service-oriented architectures

Course content

10 sections • 64 lectures

About the instructor and the course Preview 03:37

Know a little about the instructor and some interesting details of the course.

About the microservices architecture and Lumen Preview 06:25

Before starting to create things, it is important to understand the goals. See how everything should work along to the features of the microservices architecture.

Make sure you have understood the architecture you will implement with Lumen.

Answer these questions, so that you are sure that you have understood the details about the service-oriented architecture you will implement with Lumen during the course.

How to Ask Questions Preview 00:48

Through the question system, you can solve your doubts, but it is very important that you ask them in the right way to help you better.

About the development environment to use in the course Preview 01:55

Here I explain a little about the development environment that I recommend to follow the course. However, you are free to use the tools with which you feel best to follow the course.

Obtaining the Lumen structure for the authors' service Preview 05:44

It is time to obtain the structure of Lumen, using composer to start with the microservice of authors.

The source code of the course Preview 00:20

Here I share the details about the different repositories where you can find the source code of the microservices and components implemented with Lumen during the course.

Preparing the service for its correct operation Preview 05:48

Once you have the Lumen structure, you have to prepare and configure some components so that the microservice works correctly

Building the authors table with a migration of Lumen Preview 05:09

With migrations, you can create the structure of the table that will store the information related to the authors that will manage the microservice.

Creating the authors' model Preview 03:46

Through the model, you can access the full power of Eloquent, the ORM of Lumen, to manage the authors of the microservice easily.

Creating a factory for authors and building test values Preview 06:07

Creating a Factory for the authors in the microservice will allow to easily generating test data that will help fill the database with Lumen.

Creating the controller for authors Preview 04:31

The controller will allow you to build the actions that will be in charge of managing the authors of the microservice, all through Lumen and its ORM.

Creating the routes for CRUD operations on the authors Preview 05:10

The routes will help you build that bridge between the actions of your controller and the URLs through which you would access the microservice.

Normalizing the authors' microservice responses Preview 04:50

It is important that you be consistent in the format and type of responses that all your services return. In this class, you will centralize this to standardize the answers.

Make sure you understand several essential concepts and components

Before proceeding, it is a good idea to understand in detail some concepts and components that will be useful throughout the course.

Showing the list of authors from the Lumen controller Preview 03:01

The first method to implement is the index method, which will return the full list of microservice authors.

Allowing creating author instances from the controller Preview 06:01

The store method of the driver will allow you to create new author instances for the microservice. Everything, using Lumen and its ORM.

Allowing showing an author with a given id with Lumen Preview 02:55

The show method receives the path parameter that will allow you to identify a single author and return it as a response from the microservice. In addition, Lumen will help you control the possibility that this id does not exist

Allowing editing an existing author Preview 06:03

The update method will help you identify and edit an existing author of the microservice with Lumen.

Allowing deleting an existing author Preview 02:56

By implementing the destroy method of the driver, you can remove an existing author from the microservice.

Handling important errors and exceptions with Lumen Preview 07:59

You must make sure you are consistent in all possible microservice responses, and that includes error responses as well.

Getting the structure of Lumen for the book microservice Preview 03:49

Get the structure of Lumen, using composer to start with the microservice of books

Preparing the books microservice Preview 03:15

You must prepare and configure some components of Lumen so that the microservice works correctly

Creating the table for books with migrations Preview 03:58

With the migrations, you will create the structure of the table that will contain the information related to the books that this microservice is responsible for.

Creating the model for books Preview 02:16

Through the model, you can access the full power of Eloquent, the ORM of Lumen, and manage the books of this microservice easily.

Creating a factory for books and generating random values Preview 03:29

Create a Factory for the books in this microservice, and generate test data that will help fill the database with Lumen.

Creating the Lumen controller for books Preview 02:45

Build the actions that will be responsible for managing the books that will be responsible for this microservice with Lumen.

Creating the Lumen routes for CRUD operations on books Preview 02:02

The routes will help you build the bridge between the actions of your controller and the URLs through which you will access the microservice.

Standardizing the responses across the services Preview 02:25

You must maintain the same format and response structure of the authors' service in this microservice.

Showing the complete list of books Preview 01:53

The index method will allow you to return the complete list of books of this microservice.

Allowing creating new instances of books Preview 03:10

Allows you to create new instances of books, implementing the controller's store method

Allowing showing a specific book Preview 02:29

The show-receive method allows you to identify and return the details of an existing book in response to the microservice. Lumen will help you control the possibility that this id does not exist

Allowing updating an existing book Preview 03:29

The update method will allow you to identify and edit an existing microservice book with Lumen.

Allowing removing an existing book Preview 02:27

The destroy method of the controller will allow you to delete an existing microservice book.

Handling relevant errors and exceptions with Lumen Preview 03:05

Make sure you always return valid answers and in the proper format even in case of error.

Creating the Lumen project for the API Gateway using Composer Preview 02:46

Get the structure of a new Lumen project where you will implement all the components of the Gateway API.

Preparing Lumen for the API Gateway Preview 02:27

Configure the Gateway to function and act correctly with Lumen.

Creating the controllers for the authors and books Lumen microservices Preview 03:16

The Gateway will center the functions of all the microservices so it will be necessary to create Lumen controllers for each one

Unifying Lumen responses for the API Gateway Preview 04:38

You must maintain the format and structure of the answers in all your microservices, and this includes especially the Gateway that must centralize everything.

Registering routes for microservices in Lumen from the Gateway Preview 02:22

The Gateway API with Lumen will have the union of all the possible routes of the microservices to attend and direct each one of the correct ways.

Preparing the Gateway in Lumen to consume services Preview 06:06

You must give the ability to redirect requests to the correct service, consuming them through HTTP with Lumen and GuzzleHttp.

Preparing the Lumen components to consume the internal services Preview 07:05

It is necessary to prepare and build the necessary structures that will allow particularizing the way in which the Gateway can consume the other Lumen microservices.

Obtaining the list of authors from the authors' Lumen microservice Preview 04:18

Consume the authors' service to obtain and return the complete list of authors. Everything must work through the Gateway Controllers.

Creating an author instance with the authors' service Preview 03:15

Consume the authors' service to create and return a new author, using the controllers and services of the Gateway with Lumen.

Showing an author instance using the authors' Lumen microservice Preview 02:12

It consumes the microservice of Lumen authors to obtain and return an author, from a received identifier.

Editing author instances using the authors' service Preview 02:39

Obtain and edit an existing author through the microservice of authors and everything from the Gateway.

Deleting author instances using the authors' Lumen service Preview 02:19

Remove an author instance using the microservice from the Lumen Gateway.

Implementing operations for books based on the authors ones Preview 04:56

From the operations already implemented for authors, it is time to do something similar for the books, using the respective micro-service from Lumen.

Checking the existence of the author before creating a book Preview 04:42

The Gateway API will be in charge of verifying that an author exists before allowing creating a book.

Controlling errors obtained from services Preview 04:31

Like all other microservices, the Gateway is also susceptible to errors and must be controlled, in addition to handling the errors of the architecture's internal services.

Installing and enabling Lumen Passport components Preview 03:40

Add Passport as a dependency, which will allow you to easily implement the security for the Gateway API through OAuth2.

Preparing and configuring Lumen to use Passport Preview 07:04

You must add some components and execute some commands to allow the Gateway to protect and provide access to protected routes of the microservices architecture.

Protecting the Gateway routes with Lumen Passport Preview 04:59

Once you have everything installed and ready, you can protect all Gateway routes, so that they require a valid access token. Using Lumen Passport of course.

Obtaining and using access tokens for the Lumen API Gateway Preview 06:07

Now that your routes are protected, you must know how to obtain a valid access token that allows you to access routes protected with Lumen Passport.

Preparing the API Gateway to authenticate its requests Preview 04:52

Now, the Gateway must be able to identify itself in front of other microservices of the architecture so that these then allow access, using secret keys.

Authenticating direct access to the Lumen authors microservice Preview 05:59

Now that the Gateway can authenticate itself, it is time to avoid direct access to the author service so that only the Gateway can make requests to it.

Authenticating direct access to the microservice of books Preview 04:08

In the same way you did with the microservice for authors, it is time to proceed with the books one to avoid direct access to it.

Creating the migration for the users table in Lumen Preview 05:57

First of all, you need a table to store users. To do this, you will use a migration taken from Laravel.

Creating the controller and the routes to manage users in Lumen Preview 04:42

Now that you have where to store users, it is time to add all possible actions to users. Create, display, update and delete users.

Fixing some details related to user operations Preview 06:32

Now that you have different actions for users, it is necessary to solve some important details when creating a user.

Creating users and creating access tokens associated with users Preview 04:00

It is time to see how to create a user and use their credentials to obtain an access token.

Identifying an authenticated user through access token Preview 06:44

Now that you can have an access token associated with a user, you can protect the routes properly and also identify the user behind a received token.

Considerations to keep in mind with your microservices Preview 02:07

Now I share some comments and recommendations to continue with confidence the process with microservices and service-oriented architectures with Lumen.

Thanks for getting here Preview 01:08

There is nothing left but to thank you and congratulate you for taking the course and reaching the end.