Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PHP Microservices

You're reading from   PHP Microservices Transit from monolithic architectures to highly available, scalable, and fault-tolerant microservices

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher Packt
ISBN-13 9781787125377
Length 392 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Carlos Pérez Sánchez Carlos Pérez Sánchez
Author Profile Icon Carlos Pérez Sánchez
Carlos Pérez Sánchez
Pablo Solar Vilariño Pablo Solar Vilariño
Author Profile Icon Pablo Solar Vilariño
Pablo Solar Vilariño
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. What are Microservices? FREE CHAPTER 2. Development Environment 3. Application Design 4. Testing and Quality Control 5. Microservices Development 6. Monitoring 7. Security 8. Deployment 9. From Monolithic to Microservices 10. Strategies for Scalability 11. Best Practices and Conventions 12. Cloud and DevOps

Implementing a microservice call


Now that we know how to make a call, let's create a more complex example. We will build our battle system. As mentioned in the previous chapters, a battle is a fight between two players in order to get secrets from the loser. Our battle system will consist of three rounds, and in each round, there will be a dice throw; the user that wins the most rounds will be the winner and will get a secret from the loser's wallet.

Tip

We suggest using some testing development practices (TDD, BDD, or ATDD) as we explained before; you can see some examples in the preceding chapter. We will not include more tests in this chapter.

In the Battle microservice, we can create a function for the battle in the BattleController.php file; let's look at a valid structure method:

    public function duel(Request $request) 
    {
        return response()->json([]);
    }

Do not forget to add the endpoint on the routes.php file to link the URI to our method:

    $app-&gt...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image