Using the Pest testing framework in Symfony

Testing your code is very important as a software developer. It not only helps you prevent bugs when you’re adding or changing features, but a good test suite also gives you and your customers a lot of confidence in the stability of the product.

Testing in Symfony is fairly easy using the symfony/phpunit-bridge package. You’ll write classes containing your tests and run them, no problem. But creating the classes adds a lot of boilerplate code. What if I told you it’s possible to get rid of a lot of boilerplate code and have a nice and elegant way of writing your tests as if you’re writing an English sentence? This is where Pest comes in!

Continue Reading “Using the Pest testing framework in Symfony”

Integrating Keycloak with API Platform

Securing your API endpoints is very important to prevent unauthorized access to your systems. But how do you do this efficiently? Are you going to build a user management system from scratch? Let me introduce you to Keycloak and how to integrate it with API Platform.

What is Keycloak?

Keycloak is an open source server for identity and access management. It has a lot of awesome features which saves us, developers, from building user management tooling and login and registration systems.

Continue Reading “Integrating Keycloak with API Platform”

Tying up loose ends & Stock Portfolio API (Part 4)

In the previous part of this series we’ve talked about using the Messenger component for sending emails. We’ve also talked about how to use JWT tokens as an easy way to create tokens for account activation links or password reset links. In this part we will tie up some loose ends and we’ll start implementing the basic stock portfolio entities, which we’ll extend in the future parts.

Tying up loose ends

Custom exceptions

We’ve used some general exceptions throughout our services. If you do not catch those, API Platform will throw an Internal Server Error to the client. To combat this we’ll implement custom exceptions and map those to the correct HTTP Statuscode.

Continue Reading “Tying up loose ends & Stock Portfolio API (Part 4)”

How to create a simple application using Symfony and React Native – Part 3

In part 2 of this series we’ve added a custom endpoint to make it possible for users to register themselves. In this part we’ll add an EmailService class to send emails using the Symfony Messenger component. I’ll also show you an awesome technique for generating JWT Tokens for specific user actions like activating an account or resetting a password.

The Emailservice

Our application needs to send email messages to our users. A basic example is an account activation email with a link for users to click on. When they click on the link their account will be activated and ready for use.

Continue Reading “How to create a simple application using Symfony and React Native – Part 3”

How to create a simple application using Symfony and React Native – Part 2

In part one of this series we’ve setup the API for this project using Symfony and API Platform. In part two we’ll make this API more functional by creating a user entity and allowing users to sign up. The complete application for part 2 can be found in my github repository.

Continue Reading “How to create a simple application using Symfony and React Native – Part 2”